Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: TimeStamping images

  1. #1
    Senior Member
    Join Date
    Feb 2018
    Corvallis, OR

    TimeStamping images

    For a few weeks now, I've been working on a motion-triggered OV7670 camera application to collect and save camera images to the Teensy 4.1 SD card. Quite often, I transfer the images to the PC using an MTP responder. The problem with MTP is that the file time stamps on the PC are changed to the time of the MTP transfer. I got around that by embedding the image collection time into the file name. However, the results are long file names that are somtimes hard to scan visually.

    Since I've started using my modified tooJpeg compression library to shrink the file sizes, I've also taken advantage of the ability to add a collection time string to the comment field of the JPEG (or JFIF) file. Extracting that time string is a bit of a PITA, though. I decided I wanted a visual time stamp that would be displayed when I view the image. The TimeStamp library is my current solution.

    Here is a sample time-stamped image:
    Click image for larger version. 

Name:	test_ImageJP_0115124820.jpg 
Views:	16 
Size:	14.4 KB 
ID:	23317

    This is a QVGA image, chosen to make the timestamp larger relative to the image itself. It was JPG compressed at quality level 75 on the T4.1, which reduced the image size to about 15KBytes (from the 153.6KB of the original). As you can see, the timestamp is not messed up too much by the compression process.

    This is a minimalist library:

    1. You don't get to change the font unless you want to rewrite the character bitmaps embedded in the library.
    2. The font bitmaps are embedded in PROGMEM by default and include only the following characters: "/0123456789" and space. As a result you cannot easily modify the library to add other annotations to an image.
    3. The time stamp is formatted in the US default format: "mm/dd/yy hh:mm:ss". If you want another date/time format, you'll have to modify the library source.
    4: While you can change the position of the timestamp in the image and the text and background colors, there is no capability for transparency or blending of colors between the timestamp and the image.
    5. The timestamp is added to the image with a character-by-character bitblt operation. This is not a particularly efficient way to use slower, cached memory, such as EXTMEM on the Teensy 4.1. Adding a timestamp to a VGA image in EXTMEM takes about 180 microseconds on a T4.1 at 600MHz. I suspect that time could be significantly reduced by generating the time stamp in a buffer in DTCM, then transferring the timestamp bitmap as a rectangle to the destination image. It could be speeded up even more by redrawing in the timestamp bitmap only the characters that have changed in the interval since the last time stamp.

    The advantages of this minimalist approach are that the library is small, you don't have to mess with external fonts, and the user interface is very simple:

    begin() Sets internal variables and defaults
    SetBitMap() Called if you change the image characteristics after begin()
    SetTimeStamp() Called when you want to add the timestamp to your image
    GetTimeString() Returns a pointer to the last generated timestamp string.

    The library can be downloaded from the GitHub repository at:

    I'll be adding the TimeStamp capability to some of the demos for the OV7670 library and the PXP library.

  2. #2
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    Nice work! >> and colon >> characters: ":/0123456789" and space.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts