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

Thread: CSI Camera Library

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

    CSI Camera Library

    In a thread on the technical support forum https://forum.pjrc.com/threads/63195...IRQ-Teensy-4-0
    I've been working with the OV7670 camera and a number of different hardware implementations with the OP, Cyrille, and the usual list of suspects. I've decided that it is time to convert a lot of our work to a library and I have a few questions:

    1. Should I work on a generic library that can handle multiple different cameras, or concentrate on the OV7670, which is not only cheap ($5 per unit on Amazon), but pretty capable (VGA resolution at 30FPS)?

    2. Should I follow the example of the Hardware Serial libraries and have the library just instantiate a single CSI_Camera object or should the library be more like the IntervalTimer and allow multiple instantiations? There is a strong argument for the former in that the T4.1 has only one CSI interface and there is no simple way to connect multiple cameras. That also makes it simpler to handle interrupt routines, which can get tricky with multiple objects.

    3. How does the library handle the fact that a VGA RGB565 image is about 614400 bytes and can only be easily captured using the PSRAM in EXTMEM? Smaller images, like QVGA (320x240) can be captured in the T4.1 DMAMEM, but how should the object check for frame buffer memory size?

    4. How will the class handle various output formats: Frame buffer sent to Serial for upload to PC, Frame Buffer written to SD card, Frame buffer windowed to transfer to a connected LCD display?

    This object will only be available on the T4.1, as it is the only Teensy that has the CSI pins led to user-available pins.

    The easy way out would be to write a library that only handles the OV7670 with a limited number of output formats. I may start that way, but I don't want to paint myself into a corner when there are lots of other camera module that may work with the T4.1 CSI.

  2. #2
    Senior Member
    Join Date
    Feb 2018
    Location
    Corvallis, OR
    Posts
    243

    OV7670 library

    Here is a first attempt at an OV7670 library. It has a very simple API and I am looking for suggestions on additions. I will look at the Arduino_OV7670_Master code for possible additions.

    There are only three small examples. The most complex of these implements an MTP responder to transfer .bmp files to a Windows computer for display.

    OV7670.zip

    Just as the SD library instantiates an object named "SD", this library instantiates and object named "OV7670". There is just this single object since only one camera can be attached to the CSI hardware at a time. Having a single named object also greatly simplifies the code for the CSI IRQ handler.

  3. #3
    Senior Member
    Join Date
    Feb 2018
    Location
    Corvallis, OR
    Posts
    243
    I've posted a new version of the OV7670 library. Here are a few of the changes:

    * Fixed a bug where the .bmp file header was not properly updated when changing the camera window size.
    * Added support for sampling pixels for motion detection
    * Added sample code for time-lapse capture of images.
    * Added sample code for motion-triggered capture of images.
    * Added visible time stamps to images displayed with ILI9341 and embedded 4-byte time as first 4 bytes of bitmap file.

    The new sample code requires the SD updates in TD 1.54B4 or later. Several examples use MTP file transfer--which seems to be in the process of getting updated. When TD1.54 is released, I will review my implementation of the MTP responder and make sure it is compatible with the latest version of the MTP library.

    OV7670_1.zip

Posting Permissions

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