Page 1 of 2

Focus Assistant with Python Script

Posted: Fri Aug 07, 2026 7:31 pm
by StarFlea
Hi Robin,

I’ve run into another display issue that has been bothering me for a while.

I use a sequencer step to call a Python script designed to launch a Focus Assistant—for example, "Contrast (Edge) Detection" or "Bahtinov Mask."

Example:

Code: Select all

SharpCap.Transforms.SelectTransform("Contrast (Edge) Detection")
When triggered via the script, the history graph frequently remains blank (happening in about 25–50% of cases).
Screenshot:
Graph1.jpg
Graph1.jpg (134 KiB) Viewed 659 times

It seems that all focus assistants are affected by this issue.

Unfortunately, I cannot reliably reproduce this behavior, but it seems to occur more often when I am connected to a real camera (rather than a test camera). There are no issues when I start a Focus Assistant manually.

Regards,
StarFlea

Re: Focus Assistant with Python Script

Posted: Sat Aug 08, 2026 8:35 am
by admin
Hi,

OK, I will investigate - probably to do with the thread that the python scripting runs in not being the UI thread - some things are sensitive to that.

cheers,

Robin

Re: Focus Assistant with Python Script

Posted: Sat Aug 08, 2026 9:11 am
by admin
Hi,

I trimmed your sequence down to cut out the parts to do with the mount movement etc :

Code: Select all

SEQUENCE
    CAMERA OPEN "Mars-C (IMX462)"
    DELAY 2
    RUN PYTHON FROM C:\Users\robin\Downloads\ContrastDetection.py
    PROMPT "Press OK to Continue." ENABLECONTROLS True
END SEQUENCE
I tested that several times with the camera sat on my desk with a small lens on it and had no issues. Is the camera continuing to send frames once the focus tool is open? It looks like it from the high frame count in your screenshot, but work checking. Is there anything in the log indicating a possible error?

cheers,

Robin

Re: Focus Assistant with Python Script

Posted: Mon Aug 10, 2026 9:41 am
by admin
Hi,

when you get a chance, please try with beta version 4.2.15037 - I added some diagnostic text that should appear in that area if the graph fails to show for some reason (if the graph does show correctly then the graph will be in front of it, so no one will see the text unless something bad has happened).

Knowing if you see that text or not, and if you do see it what the message is, will help narrow down the potential causes of this issue.

cheers,

Robin

Re: Focus Assistant with Python Script

Posted: Tue Aug 11, 2026 2:31 pm
by StarFlea
Hi Robin,

it seems I can't reproduce the problem in a simulation. Once the weather improves, I'll set aside some specific time at night to look into it again.
It appears a real camera is actually required...

However, I just noticed something else in the screenshot: a focus assistant normally opens two tabs ("History" and "Graph"). If the "History" tab remains empty when opened via script, it seems the "Graph" tab doesn't open either.

Regards,
StarFlea

Re: Focus Assistant with Python Script

Posted: Wed Aug 12, 2026 4:34 pm
by admin
Hi,

no problem - let me know if you discover anything.

The 'Graph' tab appears if you have

* A connected ASCOM focuser _and_
* At least one focus measurement value has been collected

I should probably deal with that second condition show that the tab with an empty graph shows up with just the focuser connected. If you are taking 1-2s exposures it doesn't really matter, but with longer exposures or requiring multiple samples to make a measurement, it can be confusing.

cheers,

Robin

Re: Focus Assistant with Python Script

Posted: Thu Aug 13, 2026 8:30 am
by StarFlea
Okay, then it’s just a coincidence, because I don’t use a focuser.

Unfortunately, my new mount broke down yesterday before the solar eclipse. I have to wait for a replacement first...

Re: Focus Assistant with Python Script

Posted: Thu Aug 13, 2026 3:13 pm
by admin
Hi,

sorry to hear about the broken mount - that's an absolute nightmare happening just at that time :(

Hope you managed to salvage at least something from the eclipse even if just phone cam pictures through a pair of eclipse glasses...

cheers,

Robin

Re: Focus Assistant with Python Script

Posted: Thu Aug 13, 2026 3:36 pm
by StarFlea
No, I got so fed up that I packed everything back up and went for a walk instead.
Two weeks of preparation went completely to waste!
The mount failed just 10 minutes before the eclipse began. Probably a problem with the drive mechanism...

And there wasn't enough time left to go home and get my old backup mount.

But in the meantime, I could run a few tests with this one and see if I can trigger the problem...

Cheers!
StarFlea

Re: Focus Assistant with Python Script

Posted: Sun Aug 23, 2026 3:52 pm
by StarFlea
Hi Robin,

I ran another test with the sun today and kept a detailed log with additional informations. I’ve packed the log and all other relevant files into the ZIP file.

Right from the first attempt, the History tab remained blank again. The log file contains the time window in question for the Contrast (Edge) Detection call, spanning from 17:00:58.103765 ​​to 17:00:58.665468.

However, at first glance, I can't spot anything that might be helpful...

But maybe you'll see something...

cheers,
StarFlea