Saving video and timestamps

Discussion related to "under the hood" OpenMV topics.
iScienceLuvr
Posts: 25
Joined: Thu Apr 26, 2018 6:55 pm

Saving video and timestamps

Postby iScienceLuvr » Thu Apr 26, 2018 6:59 pm

I am trying to save a video, and also save its corresponding timestamps from openMV to my computer. How exactly would I do that? I know I can save a video with the frame buffer, but that does not have timestamps. I could record the timestamps and save them along with the video onto an SD card, but i don't want to save it onto an SD card and then have to transfer it onto the computer. Is there a way to save the video and timestamps from OpenMV to my computer?
User avatar
kwagyeman
Posts: 2387
Joined: Sun May 24, 2015 2:10 pm

Re: Saving video and timestamps

Postby kwagyeman » Thu Apr 26, 2018 8:16 pm

Hi, you can use the draw_string method to draw the time stamp on the frame buffer. For he next release we upgraded the method to allow for font scaling but for the current firmware it's pretty basic. Um, anyway, give the draw_string() method a try.
Nyamekye,
iScienceLuvr
Posts: 25
Joined: Thu Apr 26, 2018 6:55 pm

Re: Saving video and timestamps

Postby iScienceLuvr » Thu Apr 26, 2018 11:02 pm

Thanks, but this doesn't allow me to access the timestamps for further processing... I would now have to do some OCR or something to access it? Is there not a better way?
User avatar
kwagyeman
Posts: 2387
Joined: Sun May 24, 2015 2:10 pm

Re: Saving video and timestamps

Postby kwagyeman » Fri Apr 27, 2018 1:50 am

Hi, you can print data to the serial port... note that you can print both the jpeg compressed image and text to the serial port. Um, do you need a pointer on this?

Simple:

print(img.snapshot().compress())

Will print image data... That said, it's in binary and will mess up any terminal program that receives it. We also support:

print(img.snapshot().compress_for_ide())

Which manipulates the data before sending it to avoid text overlap. If you need the code to them convert the data back into a regular jpeg byte stream I can provide it in C.
Nyamekye,
iScienceLuvr
Posts: 25
Joined: Thu Apr 26, 2018 6:55 pm

Re: Saving video and timestamps

Postby iScienceLuvr » Fri Apr 27, 2018 2:32 am

Is it possible to convert it back to video stream using python. Unfortunately, I do not use C. I have never used serial before (except with an Arduino I think).
User avatar
kwagyeman
Posts: 2387
Joined: Sun May 24, 2015 2:10 pm

Re: Saving video and timestamps

Postby kwagyeman » Fri Apr 27, 2018 11:23 am

Yes, we have a control script for the OpenMV Cam that you can use. Please see our github/openmv/usr/OpenMV.py script.
Nyamekye,
iScienceLuvr
Posts: 25
Joined: Thu Apr 26, 2018 6:55 pm

Re: Saving video and timestamps

Postby iScienceLuvr » Fri Apr 27, 2018 9:44 pm

What is the usage of this script? Also, is it possible to save a video using this script? Is it possible for the data to be processed by another program, like an OpenCV program?
User avatar
kwagyeman
Posts: 2387
Joined: Sun May 24, 2015 2:10 pm

Re: Saving video and timestamps

Postby kwagyeman » Fri Apr 27, 2018 10:42 pm

The script uses numpy to store an iamge in a numpy array. It's really not anything other than a starting point for talking to the camea. Given the questions you are asking I'm guessing you like something more turn key.

Unfortunately, I don't have the ability to offer any more than than being able to pull images into a numpy array for python right now.
Nyamekye,
iScienceLuvr
Posts: 25
Joined: Thu Apr 26, 2018 6:55 pm

Re: Saving video and timestamps

Postby iScienceLuvr » Sat Apr 28, 2018 12:26 am

Ok, but still, what is the usage of the script?
User avatar
kwagyeman
Posts: 2387
Joined: Sun May 24, 2015 2:10 pm

Re: Saving video and timestamps

Postby kwagyeman » Sat Apr 28, 2018 12:57 pm

Hi, please see the python code here:

https://github.com/openmv/openmv/blob/m ... /openmv.py
Nyamekye,
iScienceLuvr
Posts: 25
Joined: Thu Apr 26, 2018 6:55 pm

Re: Saving video and timestamps

Postby iScienceLuvr » Sat Apr 28, 2018 4:18 pm

I know, but I ask because the code wasn't very well commented/documented. So like what's the output? It prints some

Code: Select all

tx_buf(tx_len)
but what is that? And the input is the OpenMV script?
User avatar
kwagyeman
Posts: 2387
Joined: Sun May 24, 2015 2:10 pm

Re: Saving video and timestamps

Postby kwagyeman » Sat Apr 28, 2018 5:17 pm

It's basically sending a command to the camera to execute a python script.

Code: Select all

x_len = tx_buf_len()
    if (tx_len):
        print(tx_buf(tx_len))
Then prints the result of the script if there was an error. Otherwise the script that you sent to the camera will run and the one of the PC will exit. If you'd like to then grab image data and text output you must add a loop of doing:

Code: Select all

x_len = tx_buf_len()
    if (tx_len):
        print(tx_buf(tx_len))
And also:

fb_dump()
Nyamekye,

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 4 guests