When I retrieve object information from pixy over i2c, I need to know the time elapsed since the exposure was taken +/- ~2ms so that I can synthesize an accurate timestamp for the exposure. Is this possible/can someone point me to the relevant parts of the source code?
Hello Jonathan,
You might check with getBlock() in blobs.cpp. This is where the block data is generated. The actual frame time might be challenging to encode, but this takes place in the M0 processor in rls_m0.c.
Hope this helps!
Edward
Thanks Edward,
I’ve spent the last hour poking through the code. I’ll tell you what I now think I know, and maybe you can tell me if I’m wrong… (FYI: I’m looking at the IR-LOCK version of the pixy source, which is quite old)
- getBlock is called at the beginning of an i2c transaction, as far as I can tell, which means I know when the transaction starts.
- The camera has a rolling shutter according to the datasheet. Not so great, but we’ll work with it… If I know the exposure time I can probably even generate a separate timestamp for each object in the scene.
- The horribly-named “skipLines” function actually means “wait for vsync.”
- I can get the current automatic exposure control value by calling cam_getAEC()
- LPC_TIMER2->TC is the system time in 32-bit microseconds beginning from 0 at boot. Great.
Here’s what I don’t know:
- When the vsync pulse happens relative to the beginning or end of an exposure. It’s ok to not know this, since I set out primarily to eliminate the variable latency from being asynchronous.
- How to compute the exposure time in microseconds from the AEC value. It is also ok to not know this.
Ah, I don’t have the correct datasheet, and the correct datasheet is only available under NDA, apparently.
Hmm, probably missing another detail: the frame time needs to stick with the frame data as it gets processed, which I assume happens on the M4…
Ah I see, serial and blobification are done on the m4, while the m0 reads the camera. Is there a shared timer?
Ah, looks like timer2 is shared. Great. I’ll just cram the system time into the qqueue right after the 0xffffffff and that’ll do it.
Hello Jonathan,
It sounds like you found the right location. I assume this is on the M0 side. Nice work!
Edward
Yep, I have the code built but I have yet to test it. Thanks.