Plate Solve Index stars list

Discussions on extending SharpCap using the built in Python scripting functionality
User avatar
admin
Site Admin
Posts: 17344
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Plate Solve Index stars list

#11

Post by admin »

To make this sort of filtering easier, I have also added a 'HaversineTo' method to the RADecPosition class - this allows you to quickly calculate the haversine angular distance between two sets of co-ordinates in (relatively fast) c# code, rather than having to do it in slower Python.

cheers,

Robin
Jean-Francois
Posts: 822
Joined: Sun Oct 13, 2019 10:52 am
Location: Germany

Re: Plate Solve Index stars list

#12

Post by Jean-Francois »

Hello Robin,

Here a small script showing the stars from the PlateSolve database on the image:

Code: Select all

import os
import math
import time
import clr
clr.AddReference("System.Drawing")
clr.AddReference("System.Windows.Forms")

import System.Drawing
import System.Windows.Forms

from System import EventHandler
from System.Drawing import *
from System.Drawing.Drawing2D import *
from System.Threading import CancellationToken
from SharpCap.Base import CoordinateParser, RADecPosition, Epoch
from SharpCap.Interfaces import PlateSolvePurpose


coordinates  = SharpCap.BlindSolver.Solve(PlateSolvePurpose.Annotation, CancellationToken())
corner       = SharpCap.PixelPositionProvider.MapPixel(PointF(0, 0))
field        = coordinates.HaversineTo(corner)
StarsNear    = SharpCap.GetPlateSolveStarsNear(coordinates)

List   = []
Radius = 5       # Circle radius
pen_color  = Pen(Color.FromName("Red"), 1.0)

StarsField = 0

for i in range(0, StarsNear.Count):
    if StarsNear[i].Position.HaversineTo(coordinates) < field:  #0.2: #field:
        StarsField = StarsField + 1
        Star_coord = SharpCap.PixelPositionProvider.MapCoordinate(StarsNear[i].Position)
        List.append(Star_coord)
        print(StarsNear[i].Position, str("%.6f" % round(StarsNear[i].Position.HaversineTo(coordinates), 6)).rjust(9), str("%6.2f" % round(StarsNear[i].Magnitude, 2)).rjust(6), end=' ', flush=True)
        print(str("%7.1f" % round(float(Star_coord.X), 1)).rjust(5), str("%7.1f" % round(float(Star_coord.Y), 1)).rjust(5))

print()
print("Total Count    :", StarsNear.Count)
print("Stars in Field :", StarsField)

def framehandler(sender, args):
    dbitmap = args.Frame.GetAnnotationGraphics("Test")
    for i in range(0, StarsField):
        dbitmap.DrawEllipse(pen_color, List[i].X - Radius + 0.5, List[i].Y - Radius + 0.5, 2*Radius, 2*Radius)
    dbitmap.Dispose()


if k > 0:       # At least one star to show
    SharpCap.SelectedCamera.BeforeFrameDisplay += framehandler
    time.sleep(5)
    SharpCap.SelectedCamera.BeforeFrameDisplay -= framehandler

Here 3 examples with (manual) smaller field for the 3 star index of the SharpSolve.
ASTAP or PlateSolve 2/3 can be used for the plate solve ... but only the "last" selection of the SharpSolve index will be used/showed.
PlatSolve_Stars_Default.jpg
PlatSolve_Stars_Default.jpg (437.56 KiB) Viewed 287 times
PlatSolve_Stars_Hi-Res.jpg
PlatSolve_Stars_Hi-Res.jpg (439.89 KiB) Viewed 287 times
PlatSolve_Stars_Ultra-Hi-Res.jpg
PlatSolve_Stars_Ultra-Hi-Res.jpg (444.49 KiB) Viewed 287 times

Regards,
Jean-Francois
User avatar
admin
Site Admin
Posts: 17344
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Plate Solve Index stars list

#13

Post by admin »

Hi Jean-Francois,

thanks for sharing, that's an interesting visualization of the plate solving index stars.

The code that builds the plate solving index tries to pick stars that are roughly evenly distributed by dividing the sky up into small sub-areas and trying to get at least a minimum number of stars in each sub-area. Obviously, that doesn't always work out as nicely as you might think - as demonstrated by the gaps in the final image.

cheers,

Robin
Post Reply