A Couple of small feature requests

Got an idea for something that SharpCap should do? Share it here.
Forum rules
'+1' posts are welcome in this area of the forums to indicate your support for a particular feature suggestion. Suggestions that get the most +1's will be seriously considered for inclusion in future versions of SharpCap.
Borodog
Posts: 485
Joined: Fri Jan 01, 2021 7:25 pm

Re: A Couple of small feature requests

#11

Post by Borodog »

PS. I tried the edge detection focus algorithm and it seemed maybe to perform better than Fourier Detail. The latter seems to often return high focus scores for quite blurry images far from focus.
Borodog
Posts: 485
Joined: Fri Jan 01, 2021 7:25 pm

Re: A Couple of small feature requests

#12

Post by Borodog »

PS. I tried the edge detection method last night and it seemed a little better.
User avatar
admin
Site Admin
Posts: 17530
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: A Couple of small feature requests

#13

Post by admin »

Hi,

the trouble with all of the 'planetary' focus algorithms is trying to separate the high gain noise from the real detail...

Anyway, I was looking at the code last night and thinking to myself 'why request error bars - there already are error bars on that graph'. In fact there *are* error bars, but they are drawn in black, so are not visible when you use the dark colour scheme :( I will fix that one too in 4.1

cheers,

Robin
Borodog
Posts: 485
Joined: Fri Jan 01, 2021 7:25 pm

Re: A Couple of small feature requests

#14

Post by Borodog »

Robin,

I actually do my planetary focusing at 30-33 ms, 30-33 fps, so at very high SNR. There is no real grain apparent in Jupiter and Mars at all on the screen. Some for Saturn but not much.

I continue to struggle with both the Fourier Detail method and the Edge Detection methods. First, there is what appears to be a very large bug associated with the Edge Detection method. If you have Feature Tracking enabled using CoG, the gray box indicating the black level in the Edge Detection focus box is detected by the Feature Tracking algorithm and it goes nuts. I could drag the telescope around by moving the focus box. That makes it not exactly useless, but clearly not what I want.

Second, both methods continue to sometimes return higher scores for what is clearly worse focus. This occurs when the seeing is less than perfect, but it isn't terrible either. *I* can clearly see it is worse focus, and as I said, my planetary SNR is actually very high. In any event, this causes failures to find a fit and best focus.

Lastly, I've noticed a tendency for the initial focus score to "jump" significantly when the focuser moves to the next step in the focus sweep, to a very high score, and it spends the next several samples drifting down toward where it wants to end up. Perhaps I am being fooled by randomness, but it seems to be a clear pattern. I am wondering if the first sample after a focus move should be thrown out because it is producing a spurious high score for some reason.

I have not tried the Histogram Range method, as it is recommended for high noise images, which I don't have.

Perhaps the best method for planets (and maybe surfaces) would be to use all 3 methods. It doesn't seem like there would be any barrier to calculating all 3 scores and using then in the automatic focus routine. More independent measurements usually leads to better predictions.
User avatar
admin
Site Admin
Posts: 17530
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: A Couple of small feature requests

#15

Post by admin »

Hi,

thanks for the feedback :)

I will have to look into the interaction between the feature tracking and the focus selection rectangle - that is not intentional, but I am a bit concerned that it might be awkward to resolve without making some serious changes to the way the image data flows through the program :(

For the cases where the score seems to peak in the wrong place, would you be able to capture a few still images (PNG format should be fine if you are using 8 bit) showing the image both at best focus from your point of view and at best focus according to SharpCap. Even better, a short SER at each position would include a number of frames that I can pluck apart and see if I can work out what is going on.

The data from frames collected when the focuser is moving is supposed to be ignored, although that is tricky to deal with as it's hard to know exactly when a frame was captured when running high speed imaging. When a frame arrives at SharpCap, the frame after it may already be transferring via USB, the one after that might be buffered on the camera and the one after that might be in the process of being captured. I can certainly dig into this to check nothing has gone awry though.

cheers,

Robin
Borodog
Posts: 485
Joined: Fri Jan 01, 2021 7:25 pm

Re: A Couple of small feature requests

#16

Post by Borodog »

If I ever have clear skies again, I'll make a video during a focus sweep (providing the seeing isn't very good, where everything seems to work beautifully, FYI; absolutely perfect parabolae).

My understanding was that "a" focus sample is actually an average of many frames. Each focus sample takes a second or 2 to collect, depending on your settings. It seems like perhaps throwing out the first sample might be a wise precaution, or at least having the option to.

Another option would be to have rejection of bad samples before final calculation of the focus score for that position, which should make it even more robust. Again I would recommmend looking at LAR over least squares.

I have definitely seen the graph grab scores while the focuser is still moving, by the way. During the overshoot before returning to an "in" position, the graph will grab scores at more inward positions than the target position and display them. Sometimes these spurious scores get displayed with a red triangle I believe; I assume that means it doesn't count?

By the way, I have downloaded and installed the alpha, but haven't had a chance to do anything with it yet because clouds.
User avatar
admin
Site Admin
Posts: 17530
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: A Couple of small feature requests

#17

Post by admin »

Hi,

so I spent some time looking into this yesterday to try to work out what is going on.

As you say, each measurement is usually the average of several frames (you can set various options in terms of frame count or time). If the focuser position changes during the collection of a set of frames into a sample, the data collected so far is thrown away and a new sample starts being built up. Now, the limitation to this is that SharpCap only grabs the current position from the focuse a couple of times per second, so if you set say 10 frames per sample and are running at 30fps then it may be possible for a whole sample to be built up between readings of the focuser position and so to slip through the net. To counter this, there is an option that can be ticked under the 'Averaging' settings on the left to ignore frames that are captured while the focuser is moving. This was particularly aimed at longer exposures, but it should also work in the high frame rate use case - even if SharpCap is only reading the position a couple of times per second, the moving flag will be set for all that time.

I am considering whether to add an additional 'settling' time option here, so that once the focuser changes to not moving status, it will be an additional 1/2/3/whatever seconds before measurements start again.

If you get a chance to try the beta then you should find an improvement in fitting of the curve to data. I found that the current versin 4.0 was sometimes missing perfectly good curve fits due to a logic error in the way it looked for the best fit. This was more likely to happen with more closely spaced data points. I have corrected that issue, but it required some significant changes, so will not appear in SharpCap 4.0 in case there are situations where it doesn't work as well as the existing code. So far I have yet to find a data set where a L.A.R. fit gives significantly improved detection now that I have the new logic in the search for the best fit. I will keep that in reserve for when I see data that needs it.

The beta also has the ability to remove data points (right click on the one to be removed - there should be a delete entry in the context menu).

cheers,

Robin
Borodog
Posts: 485
Joined: Fri Jan 01, 2021 7:25 pm

Re: A Couple of small feature requests

#18

Post by Borodog »

Sounds good, Robin. I’m pretty sure I have the option to not take measurement while the focuser is moving checked, as it’s pretty obviously what I want.

One thing I have been thinking about recently is whether worse seeing “clips” the parabola. I have seen this several times, where it looks like there is a parabola that has been clipped, creating a flat region that the algorithm cannot detect a fit for, as if the seeing is setting a maximum limiting score. I’ve tried to expand the scan in such cases, but often seem to run into SharpCap returning higher scores for out of focus images, at least with the Fourier Detail method.

Excited to try the new alpha/beta version.
Borodog
Posts: 485
Joined: Fri Jan 01, 2021 7:25 pm

Re: A Couple of small feature requests

#19

Post by Borodog »

Ok. Super frustrating time trying to use autofocus last night. First of all, seeing was not bad:

https://www.cloudynights.com/uploads/ga ... 328688.gif

https://www.cloudynights.com/uploads/ga ... 276536.gif

I lost at least an hour trying to get (1) feature tracking, and (2) autofocus to work. Neither wanted to work. I'll talk about feature tracking in a different thread.

I tried to record a video of my painful attempts at autofocus, but found out afterward that it was not recording everything on the screen. Grrr.

Mainly I stuck with Fourier Detail detection, although I should have tried Edge Detection, as feature tracking wasn't working anyway.

The scores were just all over the map. I really don't know what I should be doing. There are so many settings and none of them seem to help, averaging, seconds vs frames, black level, noise reduction, number of samples to take, nothing seemed to produce a sensible parabolic graph that SharpCap could fit. A couple of times it found a fit, but more often than not it didn't.

Meanwhile, I recorded while doing a manual focus sweep, and Autostakkert shows this:
focus sweep.png
focus sweep.png (44 KiB) Viewed 1101 times
The peak score there is 200,000. The minimum score is 40,000. It's pretty clear that it can be done. I'm close to giving up and using this method; record a manual focus sweep, analyze it in Autostakkert, and return to the best score.
User avatar
admin
Site Admin
Posts: 17530
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: A Couple of small feature requests

#20

Post by admin »

Hi,

lovely Jupiter with moon + shadow there in the final processed output :)

Sorry to hear about the frustration - do you have the AVI/SER of the focus sweep that you loaded into Autostakkert still? If you could share that with me I could run various frames through the SharpCap focus measurement and hopefully work out what is going on.

The various settings can be set in a fairly systematic manner...

1) Set the black threshold so that the area outside the planet but inside your selection area is shaded. The shaded areas are darker than the black threshold and do not contribute to the score. If your selection area is entirely within the planet, set the black threshold low enough that there is no shading being added. See https://docs.sharpcap.co.uk/4.0/#Settin ... ck%20Level

2) Noise reduction - initially leave at a low value, probably unlikely to need it

3) Averaging - show average score, average over 5 to 10 frames (maybe 20), ignore frames when moving

4) For a more accurate scan 3+ samples at each step (that gets you error bars on each measurement). For a quick one, one sample.

I have resolved the issue with feature tracking and the selection rectangle for SharpCap 4.1

cheers,

Robin
Post Reply