Focus Assistant with Python Script

A place to report problems and bugs in SharpCap
Forum rules
‍

If you have a problem or question, please check the FAQ to see if it already has an answer : https://www.sharpcap.co.uk/sharpcap-faqs

Please also read about Troubleshooting USB Issues before posting.

*** Please do not post license keys - please report any problems with licensing to 'admin' by private message ***

Please include the following details in any bug report:

* Version of SharpCap
* Camera and other hardware being user
* Operating system version
* Contents of the SharpCap log after the problem has occurred.
[If SharpCap crashes, please send the bug report when prompted instead of including the log]
StarFlea
Posts: 169
Joined: Wed Dec 21, 2022 12:22 pm

Focus Assistant with Python Script

#1

Post 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 662 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
Attachments
Focus Solar (veTEC) (ATR2600C).ini
(2.1 KiB) Downloaded 1 time
2_Focus_veTEC_Solar_v1.scs
(429 Bytes) Downloaded 3 times
ContrastDetection.py
(64 Bytes) Downloaded 4 times
User avatar
admin
Site Admin
Posts: 17510
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Focus Assistant with Python Script

#2

Post 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
User avatar
admin
Site Admin
Posts: 17510
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Focus Assistant with Python Script

#3

Post 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
User avatar
admin
Site Admin
Posts: 17510
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Focus Assistant with Python Script

#4

Post 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
StarFlea
Posts: 169
Joined: Wed Dec 21, 2022 12:22 pm

Re: Focus Assistant with Python Script

#5

Post 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
User avatar
admin
Site Admin
Posts: 17510
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Focus Assistant with Python Script

#6

Post 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
StarFlea
Posts: 169
Joined: Wed Dec 21, 2022 12:22 pm

Re: Focus Assistant with Python Script

#7

Post 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...
User avatar
admin
Site Admin
Posts: 17510
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Focus Assistant with Python Script

#8

Post 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
StarFlea
Posts: 169
Joined: Wed Dec 21, 2022 12:22 pm

Re: Focus Assistant with Python Script

#9

Post 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
StarFlea
Posts: 169
Joined: Wed Dec 21, 2022 12:22 pm

Re: Focus Assistant with Python Script

#10

Post 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
Attachments
Focus.zip
(260.36 KiB) Downloaded 2 times
Post Reply