Welcome new user! You can search existing questions and answers without registering, but please register to post new questions and receive answers. Note that due to large amounts of spam attempts, your first three posts will be manually moderated, so please be patient.
We have moved to a new forum at http://jevois.usc.edu, please check it out. The forum at jevois.org/qa will not allow new user registrations but is maintained alive for its useful past questions and answers.
Welcome to JeVois Tech Zone, where you can ask questions and receive answers from other members of the community.

Can the time on Jevois include miliseconds?

0 votes
I know that the Date Time can be set via a serial command, but it only includes YYYY.MM.DD-HH:mm:ss.

When acquiring video, it would sometimes be nice to have time resolution down to the millisecond. Is this possible? I would like to add a timestamp to when each frame is acquired.
asked Sep 17, 2018 in Programmer Questions by Billbo911 (1,110 points)

2 Answers

+1 vote
I know you can get milliseconds in the Python modules and would be really surprised if you couldn't get them in the C ones. You should be able to modify your favorite module to include ms in the output.
answered Sep 18, 2018 by PeterQuinn (1,020 points)
I guess the next question is, can you set the time including milliseconds? I figured out the command line that includes YYYY.MM.DD-HH:mm:SS, but there is no place that I know of for milliseconds.
ar you ok generally with sermark and serstamp described at http://jevois.org/doc/UserSerialStyle.html but just you would like the stamp to also have milliseconds in it? We can include that in the next release.

Otherwise as suggested by Peter if you are already running some custom python or c++ code to record video then you can use facilities of those languages (chrono in C++ and time in python, see https://stackoverflow.com/questions/1938048/high-precision-clock-in-python/1940109 )

I just tried this in the PythonSandbox module and it worked:

at top:

import time

in process():

jevois.LINFO("time is {}".format(time.time()))

enable log messages to USB in JeVois Inventor's Console and you will see time with nanosecond resolution.
+1 vote
OK, with the help and direction from PeterQuinn and JeVois, I have validated and proved exactly what I am looking for.

With a simple serial comand sent to the JeVois, you can set its internal clock to any value you desire. You can not send the milliseconds, but with careful timing of when you send the command, you can get very close to the 0 ms mark.

Once the clock on the JeVois is set, you have several options to get the current date and time back and include down to the micro second.

 With the Time library you can use time.time() to get YYYY.MM.DD-HH.mm.ss.xxxxxx .

With the Datetime library you use datetime,datetime.now(). Once you have gathered your timestamp, datetime has multiple formatting options to get your time and date information back out.
answered Sep 19, 2018 by Billbo911 (1,110 points)
...