Accurate timestamping / sync with external computer - General Help and Assistance on using CHDK stable releases - CHDK Forum

Accurate timestamping / sync with external computer

  • 1 Replies
  • 3432 Views
Accurate timestamping / sync with external computer
« on: 14 / July / 2015, 23:48:56 »
Advertisements
Hello,

I currently have a Powershot A2400IS with CHDK 1.3. I have this connected via USB to a single-board linux computer (currently using the Odroid U3). The Odroid is reading in data from an external GPS / IMU via its serial port; this is for a UAV that captures ground images.

I have a C program running on the Odroid that reads the sensor data from the serial port, shoots the images, and tags the images with the data. I have a Lua session running in the program from which I call CHDKPTP commands; I'm using remoteshoot -jpg in order to capture images. I'm currently relying on the system timestamp from the Odroid in order to synchronize the sensor data and the images - so basically getting the system time when an image capture is triggered and then getting the (interpolated) sensor data reading at that time.

I am currently getting a timestamp immediately before the rs_shoot function is called on the camera end (so just before this line). This is using CHDKPTP's sys.gettimeofday(). However, from my testing I am seeing a 0.3-0.4s delay between the time when the function is called and when the image is captured - this is when shooting with 1/1000s shutter speed at f/2.8 and 100ISO, exposure and focus locked manually with the half-shutter + AEL/AFL buttons before shooting.

My test setup right now is to take a picture of the screen on which I have 1) the system timestamp associated with each image (shown in the top pane) and 2) the actual system time when the image was captured (shown in the bottom pane). #2 is done via a bash command that provides a live clock of the system time. Here's an example:



Both times are in microseconds since epoch. In this case the time when the image was captured (1436928490377353) is about 0.33 seconds after the stamped time (1436928490047308).

I'm wondering:

a) what is the source of this delay? Does it depend on my exposure settings (beyond just shutter speed)? I still have to do more testing, but I'm wondering if it is systematic and could be calibrated out.
b) Is there a way to get a more precise timestamp from the camera itself that is also synchronized with the system clock?

I'd really appreciate it if someone could point me in the right direction on this.

Thanks,
cindy

*

Offline reyalp

  • ******
  • 14125
Re: Accurate timestamping / sync with external computer
« Reply #1 on: 15 / July / 2015, 21:52:39 »
a) what is the source of this delay? Does it depend on my exposure settings (beyond just shutter speed)? I still have to do more testing, but I'm wondering if it is systematic and could be calibrated out.
A remoteshoot will do the whole canon pre-shoot process (pressing shoot_half, waiting for get_shooting() to become true, then pressing shoot_full. This is a fairly slow and variable process, even if you have exposure and focus locked down.

If possible, I would suggest you use rsint or something like it instead. rsint does the pre-shoot and then makes the camera code wait at a point very close to the actual exposure start. You then issue an 's' command when you want the actual exposure start. The exposure should start within a several tens of milliseconds after the the command arrives.

If you are keeping exposure and focus locked down already, you can just enter rsint and send it an 's' command every time you want to shoot. If you need script control rather than sending standard input, you could still use the rsint camera side script, and probably reuse much of the rsint code.
Quote
b) Is there a way to get a more precise timestamp from the camera itself that is also synchronized with the system clock?
You can get the camera time in seconds with the lua time() function, and a 10 ms precision count of milliseconds since boot with get_tick_count(). Note these aren't aligned: get_tick_count() generally won't roll over an exact multiple of 1000 when a second of time() rolls over.

The multicam.lua script tries calculate an offset from the chdkptp side gettimeofday() to the camera get_tick_count() value, so it can schedule a shot on multiple cameras at the same real world time. There is some fudging due communication delay and other uncertainties, but it should also be good to several tens of milliseconds.
Don't forget what the H stands for.

 

Related Topics


SimplePortal © 2008-2014, SimplePortal