OV5640 FPC Camera Module ======================== The OV5640 FPC Camera Module is a compact 5MP rolling-shutter colour sensor with autofocus. It mounts to OpenMV Cam base boards through the board-to-board connector for low-profile builds. .. image:: ../ov5640-hero.jpg :alt: OV5640 :width: 400px :align: center For full datasheet, photos, and ordering see the `OV5640 product page `_. .. note:: Not supported on the OpenMV N6 at this time. Highlights ---------- * 5MP (2592x1944) rolling-shutter sensor * Autofocus, F2.0 aperture, variable focal length Usage ----- Stream QVGA (320x240) RGB565 video — the OV5640 works as a regular camera module for any image-processing pipeline:: import csi import time csi0 = csi.CSI() csi0.reset() csi0.pixformat(csi.RGB565) csi0.framesize(csi.QVGA) clock = time.clock() while True: clock.tick() img = csi0.snapshot() print(clock.fps()) The OV5640 also has an on-board JPEG compressor — set the pixformat to `csi.JPEG` and the sensor delivers compressed frames straight to the OpenMV Cam over the camera bus, so the host stays free for processing rather than encoding. Control the compression quality (0-100) with `csi.CSI.quality` — higher numbers preserve more detail at the cost of larger frames. Capture JPEG frames at 1280x720 (HD):: import csi import time csi0 = csi.CSI() csi0.reset() csi0.pixformat(csi.JPEG) csi0.framesize(csi.HD) csi0.quality(90) clock = time.clock() while True: clock.tick() img = csi0.snapshot() print(clock.fps()) Capture JPEG frames at 1920x1080 (FHD):: import csi import time csi0 = csi.CSI() csi0.reset() csi0.pixformat(csi.JPEG) csi0.framesize(csi.FHD) csi0.quality(90) clock = time.clock() while True: clock.tick() img = csi0.snapshot() print(clock.fps()) Capture JPEG frames at full 5MP — 2592x1944 (WQXGA2):: import csi import time csi0 = csi.CSI() csi0.reset() csi0.pixformat(csi.JPEG) csi0.framesize(csi.WQXGA2) csi0.quality(90) clock = time.clock() while True: clock.tick() img = csi0.snapshot() print(clock.fps()) The OV5640 has a voice-coil-actuator autofocus lens. Trigger a single autofocus pass via `csi.CSI.ioctl` with `csi.IOCTL_TRIGGER_AUTO_FOCUS` — the sensor sweeps the focus motor once and locks on whatever's in front of it:: csi0.ioctl(csi.IOCTL_TRIGGER_AUTO_FOCUS) Re-issue the ioctl any time the scene changes — the autofocus is one-shot, not continuous.