Autoguide / Star recognition and tracking routine - Feature Requests - CHDK Forum supplierdeeply

Autoguide / Star recognition and tracking routine

  • 4 Replies
  • 3349 Views
Autoguide / Star recognition and tracking routine
« on: 02 / May / 2010, 00:31:29 »
Advertisements
Looking for help developing a custom function intended for astronomy and astrophotography.

Feature:   - identify biggest brightest star in the center of an image
   - repeat exposure, identify star's new location in subsequent images
   - estimate the change in location dX, dY, and dT
   - exposure times for the images would range from 10ms to 10 seconds

   - use dX, dY, and dT to generate commands to a 2 axis controller to keep the star from moving on the image
   - the commands would be sent to the PC, and a special ASCOM compatible Windows driver sent the commands to the steppers
  
   -  there is a calibration step that determines how a command to the 2 axis controller results in a change in X,Y for the star

Progress to date

- I've tried setting up a custom function in C but have had trouble getting it defined and called properly from UBASIC


Reference material
-phd guide is an open source application that is a template for this and has code available on code.google.com  Also, I will add my notes
http://code.google.com/p/open-phd-guiding/


My basice outline


rem Author: Chris Schmidt
rem Tested on A700
rem build v 885
rem Use with caution!

@title Autoguide
@param binsize 2by2binning
@default binsize 2
@param tv exposure time
@default tv 50
@param intv exposure interval
@default intv 100
@param boxsize pixel size of search
@default boxsize 100

cls
print "Begin Autoguiding"

t=get_tick_count

print "get image"

vp_h = get_viewport_height
vp_w = get_viewport_width

img = vid_get_viewport_live_fb
cy=0
L_max=0

print "finding a star"

for y=0 to (vp_h - binsize)
   for x=0 to (vp_w-binsize)

   cy = (img[x+1+y*vp_w]+img[x+(y+1)*vp_w]+img[x+1+(y+1)*vp_w]+img[x+y*vp_w])/4
   
   if cy > L_max 
      L_max = cy
      max_x = x
      max_y = y
   endif
   next x
next y

print "draw box"

   int color;
   color=COLOR_RED;
   draw_rect( max_x, max_y, max_x+2, max_y-2,color)

print "remember star"
star_x= max_x
star_y= max_y
star_l= L_max

print "next image"

:starloop

img = vid_get_viewport_live_fb
cy=0
L_max=0

print "finding a star"

for y=(star_y-boxsize/2) to (vp_h - binsize)
   for x=(star_x-boxsize/2) to (vp_w-binsize)

   cy = (img[x+1+y*vp_w]+img[x+(y+1)*vp_w]+img[x+1+(y+1)*vp_w]+img[x+y*vp_w])/4
   
   if cy > L_max 
      L_max = cy
      max_x = x
      max_y = y
   endif
   next x
next y

print "draw box"

   int color;
   color=COLOR_RED;
   draw_rect( max_x, max_y, max_x+2, max_y-2,color)

print "find star again"

goto starloop

end
« Last Edit: 02 / May / 2010, 00:46:01 by begin_astro »

*

Offline reyalp

  • ******
  • 14118
Re: Autoguide / Star recognition and tracking routine
« Reply #1 on: 02 / May / 2010, 01:19:21 »
FWIW, I'd suggest lua is more appropriate for this. The language itself is much more flexible and C bindings are both simpler and more powerful. It's also well documented, unlike ubasic. For development, you can use peek() to read the live fb.

Note that you won't be able to reliably draw to the GUI using either scripting language, because they run in the kbd task rather than spytask which does the normal gui drawing. I'd suggest making a list of things to draw from script and processing them in the gui code each frame. Done correctly, this would a broadly useful feature by itself.

Another option: With the experimental PTP interface ( http://chdk.setepontos.com/index.php/topic,4338.0.html ), you can get the live buffer on a PC, and do all your guiding there.

Depending on what optics you are feeding the camera with, pulling anything but the brightest stars out of the live view noise may be a problem. Taking actual exposures and using the raw data would allow you to go much deeper, but would reduce your sampling rate a lot (to do this in a reasonable time, you'd want have some code run in the raw hook, rather than writing out a raw and then reading it back in lua.) You might be able to pull a bit more out of the live view by averaging several frames. To do this with reasonable speed and memory usage, you make your code just work on a small subset near the center.
Don't forget what the H stands for.

Re: Autoguide / Star recognition and tracking routine
« Reply #2 on: 03 / May / 2010, 00:27:32 »
Thank you for the advice.  I'll start with Lua...

Re: Autoguide / Star recognition and tracking routine
« Reply #3 on: 10 / June / 2010, 14:13:49 »
Although this sounds very cool, and I'm not that into astrophotography yet, why not build a two arm barn door mount and attach a motor for tracking? I've heard that it's very accurate for at least two hours.

Andy


Re: Autoguide / Star recognition and tracking routine
« Reply #4 on: 25 / July / 2011, 15:10:52 »
Any progress on autoguiding feature?
My programing skills are mediocre but I'm involved in astrophotography so if I can help somehow let me know :)

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal