Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions red_vision/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
#
# Copyright (c) 2025 SparkFun Electronics
#-------------------------------------------------------------------------------
# cv2_drivers/touch_screens/__init__.py
# red_vision/__init__.py
#
# Imports all available drivers for MicroPython OpenCV.
# Imports all available Red Vision drivers, modules, and utilities.
#-------------------------------------------------------------------------------

from . import displays
from . import cameras
from . import displays
from . import touch_screens
from .utils import colors
from .utils import memory
18 changes: 11 additions & 7 deletions red_vision/cameras/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
#
# Copyright (c) 2025 SparkFun Electronics
#-------------------------------------------------------------------------------
# cv2_drivers/cameras/__init__.py
# red_vision/cameras/__init__.py
#
# Imports all available camera drivers for MicroPython OpenCV.
# Imports all available Red Vision camera drivers.
#-------------------------------------------------------------------------------

# Import sys module to check platform
import sys
# Import the generic VideoCapture class.
from .video_capture import VideoCapture

# Import platform agnostic drivers.
from .hm01b0 import HM01B0
from .ov5640 import OV5640

# Import RP2 drivers
# Import platform specific drivers.
import sys
if 'rp2' in sys.platform:
from . import hm01b0_pio
from . import ov5640_pio
from .dvp_rp2_pio import DVP_RP2_PIO
45 changes: 0 additions & 45 deletions red_vision/cameras/cv2_camera.py

This file was deleted.

39 changes: 25 additions & 14 deletions red_vision/cameras/dvp_camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,41 +3,52 @@
#
# Copyright (c) 2025 SparkFun Electronics
#-------------------------------------------------------------------------------
# dvp_camera.py
# red_vision/cameras/dvp_camera.py
#
# Base class for OpenCV DVP (Digital Video Port) camera drivers.
# Red Vision abstract base class for DVP (Digital Video Port) camera drivers.
#-------------------------------------------------------------------------------

from .cv2_camera import CV2_Camera
from .video_capture_driver import VideoCaptureDriver

class DVP_Camera(CV2_Camera):
class DVP_Camera(VideoCaptureDriver):
"""
Base class for OpenCV DVP (Digital Video Port) camera drivers.
Red Vision abstract base class for DVP (Digital Video Port) camera drivers.
"""
def __init__(
self,
i2c,
i2c_address
i2c_address,
height = None,
width = None,
color_mode = None,
buffer = None,
):
"""
Initializes the DVP camera with I2C communication.

Args:
i2c (I2C): I2C object for communication
i2c_address (int): I2C address of the camera
height (int, optional): Image height in pixels
width (int, optional): Image width in pixels
color_mode (int, optional): Color mode to use
buffer (ndarray, optional): Pre-allocated image buffer
"""
super().__init__()

# Store I2C parameters.
self._i2c = i2c
self._i2c_address = i2c_address

# Initialize the base VideoCaptureDriver class
super().__init__(height, width, color_mode, buffer)

def _read_register(self, reg, nbytes=1):
"""
Reads a register from the camera over I2C.
Reads a register(s) from the camera over I2C.

Args:
reg (int): Register address to read
nbytes (int): Number of bytes to read from the register
reg (int): Start register address to read
nbytes (int, optional): Number of bytes to read from the register
(default: 1)

Returns:
bytes: Data read from the register
Expand All @@ -47,11 +58,11 @@ def _read_register(self, reg, nbytes=1):

def _write_register(self, reg, data):
"""
Writes data to a register on the camera over I2C.
Writes data to a register(s) on the camera over I2C.

Args:
reg (int): Register address to write
data (bytes, int, list, tuple): Data to write to the register
reg (int): Start register address to write
data (bytes, int, list, tuple): Data to write to the register(s)
"""
if isinstance(data, int):
data = bytes([data])
Expand Down
Loading