The autoguider has lot of functions, but the main one is the guiding, which is pretty simple:
- check for keyboard events
- get a picture from the camera
- find the star in the picture
- calculate the exact position of the star
- display the image on the screen
- based on the star position modify the motor speed
- draw information about the error on the screen
- display different values on the screen
After a while it took almost one second to do everything above, which means ~1 fps, and that is very slow. So I decided to optimize a bit, to reach at least 10 fps ( which means all the things mentioned above should be done in 100 ms)
I removed some unnecessary thinks, like checking the camera parameters at each step, which stayed there after i added because of some debugging.
Also it's enough to search for the star in every 5th row and column, so the search will have 25 time less steps.
After the star is found, only search for the star around the last know location.
There is no need to copy the image of the camera, that can be used for search ( if i am not modifying the data)
No need to display the picture on the screen. ( it's just almost black everywhere with one white pixel)
After several steps I reached 22.8 fps (Step 4), but unfortunately i got more and more camera errors. I checked, and it seems that the camera can only handle 15 frame/sec.
So, put back the memcopy of the picture data, and also a delay which waits until 67 millisecond to be sure the camera data is not read more frequent as it can be.
So, now, i have 15 FPS, which is not that bad..

























