Live Collimation Aid

Discussions on extending SharpCap using the built in Python scripting functionality
bvalente
Posts: 40
Joined: Mon Aug 08, 2022 4:26 pm

Re: Live Collimation Aid

#11

Post by bvalente »

new update now has palette for all the various options, improved detection for uneven/changing defocused star brightness values. Same repo
Attachments
collimation_aid_2.0.png
collimation_aid_2.0.png (164.45 KiB) Viewed 904 times
Jean-Francois
Posts: 853
Joined: Sun Oct 13, 2019 10:52 am
Location: Germany

Re: Live Collimation Aid

#12

Post by Jean-Francois »

Hello Brian,

Nice, but ...

I tried yesterday the last version, but several bugs ... (in the order of call)

line 1979 alpha_tb.TickStyle = TickStyle.None
line 1889 tabs.Padding = Padding(6, 3, 6, 3)
line 1959 pnl.BorderStyle = 1

I have W11 Pro and Home on 2 computers, SharpCap 4.1.14236 64bit ... why it works with your system and not on my computers ?

Here, if that can help a test with the "defocus star.png" image ...

Code: Select all

>>> probe_apis()
[Probe] Capturing one frame to test APIs...
[Probe] Results:
  === frame.Index ===
    Value: 1048609 (type: <class 'int'>)
  
  === frame.GetAnnotationGraphics() ===
    (no args) FAILED: GetAnnotationGraphics() takes exactly 1 argument (0 given)
    (string key) Result: <SharpCap.NewUI.AnnotationGraphics object at 0x000000000000002B [SharpCap.NewUI.AnnotationGraphics]> (type: <class 'AnnotationGraphics'>)
    (string key) Members: ['ApplyTransform', 'ClipBounds', 'Dispose', 'DrawEllipse', 'DrawImage', 'DrawLine', 'DrawLines', 'DrawRectangle', 'DrawString', 'Equals', 'FillEllipse', 'FillRectangle', 'GetHashCode', 'GetType', 'HorizontalResolution', 'MeasureString', 'MemberwiseClone', 'ReferenceEquals', 'ResetTransform', 'Restore', 'RotateTransform', 'Save', 'SaveState', 'ScaleTransform', 'SetClip', 'ToString', 'TranslateTransform', 'VisibleClipBounds']
  
  === frame.CalculateHistogram() ===
    Result: <SharpCap.Base.HistogramData object at 0x000000000000002C [SharpCap.Base.HistogramData]> (type: <class 'HistogramData'>)
    Members: ['Adjust', 'CalculateStats', 'Equals', 'GetCentilePoints', 'GetCentilePointsF', 'GetHashCode', 'GetMeansBelowCentile', 'GetSampledCDF', 'GetStats', 'GetType', 'MemberwiseClone', 'ReduceLength', 'ReferenceEquals', 'ToString', 'Values']
  
    --- GetCentilePointsF ---
    GetCentilePointsF(99.9) = Array[Single]((191.69, 191.69, 191.69, 191.69)) (type: <class 'Array[Single]'>)
    GetCentilePointsF(Array[float]) FAILED: expected Single, got Array[float]
    GetCentilePointsF(Array[Single]) FAILED: expected Single, got Array[Single]
  
    --- GetCentilePoints ---
    GetCentilePoints(99.9) = Array[Int32]((191, 191, 191, 191)) (type: <class 'Array[Int32]'>)
    GetCentilePoints(Array[float]) FAILED: expected Single, got Array[float]
    GetCentilePoints(Array[Single]) FAILED: expected Single, got Array[Single]
  
    --- GetMeansBelowCentile ---
    GetMeansBelowCentile(99.9) = Array[Single]((78.8149, 78.8153, 78.8153, 78.8149)) (type: <class 'Array[Single]'>)
  
    --- Values ---
    Type: <class 'Array[Array[Int32]]'>
    Channels: 4
    Channel 0: 256 bins, max=41659, last_nonzero_idx=202
    Channel 1: 256 bins, max=41714, last_nonzero_idx=202
    Channel 2: 256 bins, max=41714, last_nonzero_idx=202
    Channel 3: 256 bins, max=41659, last_nonzero_idx=202
  
  === frame.CutROI() ===
    (Rectangle) Result: (100x100, RGB, BitDepth=8, ColorPlanes=4, EffectiveBitDepth=8, BytesPerPixel=4, Binning=0x0 (type: <class 'BufferFrame'>)
    (Rectangle) ROI size: 100x100
    (Rectangle) GetFrameBitmap: 100x100 (works!)
    (Rectangle) Release: OK
Regards,
Jean-Francois
bvalente
Posts: 40
Joined: Mon Aug 08, 2022 4:26 pm

Re: Live Collimation Aid

#13

Post by bvalente »

Thanks Jean-Francois

It looks like that was an earlier version of the script. The three lines were subsequently fixed in a later version

I have attached the latest one to this email just to keep things simple, and i'll update the repo once done.

I also attached some example defocused star images you can use to test. you can use the high speed simulator cam with these images

Two other small updates:
- for testing and feedback now just run debug() from console and paste in the results.
- restart button on palette to restart the detection (such as for switching between simulator images)

Brian
Attachments
collimation_aid.zip
(343.52 KiB) Downloaded 5 times
Jean-Francois
Posts: 853
Joined: Sun Oct 13, 2019 10:52 am
Location: Germany

Re: Live Collimation Aid

#14

Post by Jean-Francois »

Hello Brian,

Thanks for the update.

OK, now I tested with the High-Speed-simulator (in place of Folder-Monitor- Camera). Here with a little noise added.

It works ... but still not correct or stable ... here some results on same image:
Test_1.jpg
Test_1.jpg (322.69 KiB) Viewed 874 times


In addition ... the form scaling is not adapting for 4K monitor:
Test_2.jpg
Test_2.jpg (92.31 KiB) Viewed 874 times
Regards,
Jean-Francois
bvalente
Posts: 40
Joined: Mon Aug 08, 2022 4:26 pm

Re: Live Collimation Aid

#15

Post by bvalente »

Thanks again Jean-Francois'
can you please use debug() and post the results

can you try with the other two images and see how it performs?

Thanks
Brian
bvalente
Posts: 40
Joined: Mon Aug 08, 2022 4:26 pm

Re: Live Collimation Aid

#16

Post by bvalente »

Updated script attached

should do better on display scaling (4k monitor etc.)

The "donuts" detections are a bit tricky because there's a lot of variability, so i added an option of choosing different algorithms on the Detection tab.

The test image you are using seems to do better with Threshold Crossing

Brian
Attachments
collimation_overlay.zip
(24.35 KiB) Downloaded 4 times
detectionOptions.png
detectionOptions.png (876.01 KiB) Viewed 868 times
Jean-Francois
Posts: 853
Joined: Sun Oct 13, 2019 10:52 am
Location: Germany

Re: Live Collimation Aid

#17

Post by Jean-Francois »

Hello Brian,

It works now ... but not with MONO16.
I changed in MONO8 and the donut can be found.
It is fine ... but the user need to be remembered to switch to MONO8 for the collimation.

The "Threshold Crossing" work the best.
If I used the X or Y Offset in SharpCap, the donut centre moves with it.

But the "Edge to Dark" and the "Steepest Gradient" have an offset in X direction (around 10 pixel relative to Threshold Crossing).
I think that with a very clean "static" image ... all the algorithm should give the same result (at least for the centre).

Regards,
Jean-Francois
bvalente
Posts: 40
Joined: Mon Aug 08, 2022 4:26 pm

Re: Live Collimation Aid

#18

Post by bvalente »

Thanks again Jean-Francois


I have updated the script to the attached, which includes an improved debug() that provides me more exhaustive information.

I will continue testing. At this point it will be most helpful for more and varied tests from others to tune the algorithms

Brian
Attachments
collimation_overlay.zip
(25.52 KiB) Downloaded 6 times
bvalente
Posts: 40
Joined: Mon Aug 08, 2022 4:26 pm

Re: Live Collimation Aid

#19

Post by bvalente »

One more update

- added 16 bit support (now 8 and 16 bit support)
- added a target histogram so we can avoid problems when the collimation donut is too bright or dim
- changed inside donut detection to be more robust
- defaulted the detection algorithm to threshold crossing, which seems to be generally the most robust
- added some more test stars

Feedback and (especially) testing welcome

Brian
target_histo.png
target_histo.png (252.96 KiB) Viewed 845 times
Attachments
defocus_star_5.png
defocus_star_5.png (68.43 KiB) Viewed 845 times
defocus_star_4.png
defocus_star_4.png (22.65 KiB) Viewed 845 times
defocus_star_3.png
defocus_star_3.png (22.99 KiB) Viewed 845 times
collimation_overlay.zip
(27.13 KiB) Downloaded 7 times
bvalente
Posts: 40
Joined: Mon Aug 08, 2022 4:26 pm

Re: Live Collimation Aid

#20

Post by bvalente »

latest version attached and available in the repo

Continuing improvements. Under real world night sky it's performing well for me.

the detection algorithms all produce similar correction results. It is still worth auditioning the three to see what one works best for your image. Algorithm hints now attached to the algorithm choices.


Changes:
- now has out-of-focus star size helper
- detection algorithm hints
- improved detection of smaller donuts
- refined interface for when zooming in on display
- removed menu bar button, UI is fully palletized

instructions on the readme at the repo: https://github.com/bvalente22/sharpcap- ... on-overlay

if you have any issues, run debug() from the console and paste results.

Brian
sample_screen.png
sample_screen.png (279.8 KiB) Viewed 797 times
Attachments
collimation_overlay.zip
(28.39 KiB) Downloaded 16 times
Post Reply