mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Merge pull request #1455 from kwagyeman/kwabena/frog_eye
Add basic frogeye2020 driver
This commit is contained in:
commit
58e89f124a
39
scripts/examples/OpenMV/37-Event-Cameras/frogeye2020.py
Normal file
39
scripts/examples/OpenMV/37-Event-Cameras/frogeye2020.py
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# This example shows off using the frogeye2020 event camera.
|
||||||
|
#
|
||||||
|
# The frogeye2020 is a 320x240 event camera. There are two bits per pixel which show no motion,
|
||||||
|
# motion in one direction, or motion in another direction. The sensor runs at 50 FPS.
|
||||||
|
|
||||||
|
import sensor, image, time
|
||||||
|
|
||||||
|
sensor.reset()
|
||||||
|
sensor.set_pixformat(sensor.GRAYSCALE)
|
||||||
|
sensor.set_framesize(sensor.QVGA)
|
||||||
|
|
||||||
|
palette = image.Image(1, 256, sensor.RGB565)
|
||||||
|
|
||||||
|
for i in range(64):
|
||||||
|
palette.set_pixel(0, i, (0, 0, 0))
|
||||||
|
|
||||||
|
for i in range(64, 128):
|
||||||
|
palette.set_pixel(0, i, (255, 0, 0))
|
||||||
|
|
||||||
|
for i in range(128, 192):
|
||||||
|
palette.set_pixel(0, i, (0, 0, 255))
|
||||||
|
|
||||||
|
for i in range(192, 256):
|
||||||
|
palette.set_pixel(0, i, (0, 255, 0))
|
||||||
|
|
||||||
|
clock = time.clock()
|
||||||
|
|
||||||
|
while(True):
|
||||||
|
clock.tick()
|
||||||
|
|
||||||
|
img = sensor.snapshot()
|
||||||
|
# Handle sensor rotation.
|
||||||
|
img.assign(hmirror=True, vflip=True)
|
||||||
|
# Make pretty.
|
||||||
|
img.to_rainbow(color_palette=palette)
|
||||||
|
# Cleanup noise.
|
||||||
|
img.erode(1)
|
||||||
|
|
||||||
|
print(clock.fps())
|
||||||
@ -0,0 +1,45 @@
|
|||||||
|
# This example shows off using the frogeye2020 event camera with tracking.
|
||||||
|
#
|
||||||
|
# The frogeye2020 is a 320x240 event camera. There are two bits per pixel which show no motion,
|
||||||
|
# motion in one direction, or motion in another direction. The sensor runs at 50 FPS.
|
||||||
|
|
||||||
|
import sensor, image, time
|
||||||
|
|
||||||
|
sensor.reset()
|
||||||
|
sensor.set_pixformat(sensor.GRAYSCALE)
|
||||||
|
sensor.set_framesize(sensor.QVGA)
|
||||||
|
|
||||||
|
palette = image.Image(1, 256, sensor.RGB565)
|
||||||
|
|
||||||
|
for i in range(64):
|
||||||
|
palette.set_pixel(0, i, (0, 0, 0))
|
||||||
|
|
||||||
|
for i in range(64, 128):
|
||||||
|
palette.set_pixel(0, i, (255, 0, 0))
|
||||||
|
|
||||||
|
for i in range(128, 192):
|
||||||
|
palette.set_pixel(0, i, (0, 0, 255))
|
||||||
|
|
||||||
|
for i in range(192, 256):
|
||||||
|
palette.set_pixel(0, i, (0, 255, 0))
|
||||||
|
|
||||||
|
clock = time.clock()
|
||||||
|
|
||||||
|
while(True):
|
||||||
|
clock.tick()
|
||||||
|
|
||||||
|
img = sensor.snapshot()
|
||||||
|
# Handle sensor rotation.
|
||||||
|
img.assign(hmirror=True, vflip=True)
|
||||||
|
# Make pretty.
|
||||||
|
img.to_rainbow(color_palette=palette)
|
||||||
|
# Cleanup noise.
|
||||||
|
img.erode(1)
|
||||||
|
|
||||||
|
blobs = img.find_blobs([(0, 0)], invert=True,
|
||||||
|
pixels_threshold=10, area_threshold=10, merge=False)
|
||||||
|
|
||||||
|
for blob in blobs:
|
||||||
|
img.draw_rectangle(blob.rect(), color=(0, 255, 0))
|
||||||
|
|
||||||
|
print(clock.fps())
|
||||||
@ -39,6 +39,7 @@ SRCS += $(addprefix sensors/, \
|
|||||||
hm01b0.c \
|
hm01b0.c \
|
||||||
gc2145.c \
|
gc2145.c \
|
||||||
paj6100.c \
|
paj6100.c \
|
||||||
|
frogeye2020.c \
|
||||||
)
|
)
|
||||||
|
|
||||||
SRCS += $(addprefix imlib/, \
|
SRCS += $(addprefix imlib/, \
|
||||||
|
|||||||
@ -44,6 +44,7 @@
|
|||||||
#define OMV_ENABLE_LEPTON (0)
|
#define OMV_ENABLE_LEPTON (0)
|
||||||
#define OMV_ENABLE_HM01B0 (0)
|
#define OMV_ENABLE_HM01B0 (0)
|
||||||
#define OMV_ENABLE_PAJ6100 (0)
|
#define OMV_ENABLE_PAJ6100 (0)
|
||||||
|
#define OMV_ENABLE_FROGEYE2020 (0)
|
||||||
|
|
||||||
// Set which OV767x sensor is used
|
// Set which OV767x sensor is used
|
||||||
#define OMV_OV7670_VERSION (75)
|
#define OMV_OV7670_VERSION (75)
|
||||||
|
|||||||
@ -57,6 +57,7 @@
|
|||||||
#define OMV_ENABLE_LEPTON (0)
|
#define OMV_ENABLE_LEPTON (0)
|
||||||
#define OMV_ENABLE_HM01B0 (0)
|
#define OMV_ENABLE_HM01B0 (0)
|
||||||
#define OMV_ENABLE_PAJ6100 (0)
|
#define OMV_ENABLE_PAJ6100 (0)
|
||||||
|
#define OMV_ENABLE_FROGEYE2020 (0)
|
||||||
|
|
||||||
// Enable sensor features
|
// Enable sensor features
|
||||||
#define OMV_ENABLE_OV5640_AF (0)
|
#define OMV_ENABLE_OV5640_AF (0)
|
||||||
|
|||||||
@ -57,6 +57,7 @@
|
|||||||
#define OMV_ENABLE_LEPTON (0)
|
#define OMV_ENABLE_LEPTON (0)
|
||||||
#define OMV_ENABLE_HM01B0 (0)
|
#define OMV_ENABLE_HM01B0 (0)
|
||||||
#define OMV_ENABLE_PAJ6100 (0)
|
#define OMV_ENABLE_PAJ6100 (0)
|
||||||
|
#define OMV_ENABLE_FROGEYE2020 (0)
|
||||||
|
|
||||||
// Enable sensor features
|
// Enable sensor features
|
||||||
#define OMV_ENABLE_OV5640_AF (0)
|
#define OMV_ENABLE_OV5640_AF (0)
|
||||||
|
|||||||
@ -64,6 +64,7 @@
|
|||||||
#define OMV_ENABLE_LEPTON (1)
|
#define OMV_ENABLE_LEPTON (1)
|
||||||
#define OMV_ENABLE_HM01B0 (0)
|
#define OMV_ENABLE_HM01B0 (0)
|
||||||
#define OMV_ENABLE_PAJ6100 (1)
|
#define OMV_ENABLE_PAJ6100 (1)
|
||||||
|
#define OMV_ENABLE_FROGEYE2020 (1)
|
||||||
|
|
||||||
// Set which OV767x sensor is used
|
// Set which OV767x sensor is used
|
||||||
#define OMV_OV7670_VERSION (70)
|
#define OMV_OV7670_VERSION (70)
|
||||||
|
|||||||
@ -67,6 +67,7 @@
|
|||||||
#define OMV_ENABLE_LEPTON (1)
|
#define OMV_ENABLE_LEPTON (1)
|
||||||
#define OMV_ENABLE_HM01B0 (0)
|
#define OMV_ENABLE_HM01B0 (0)
|
||||||
#define OMV_ENABLE_PAJ6100 (1)
|
#define OMV_ENABLE_PAJ6100 (1)
|
||||||
|
#define OMV_ENABLE_FROGEYE2020 (1)
|
||||||
|
|
||||||
// Enable sensor features
|
// Enable sensor features
|
||||||
#define OMV_ENABLE_OV5640_AF (0)
|
#define OMV_ENABLE_OV5640_AF (0)
|
||||||
|
|||||||
@ -64,6 +64,7 @@
|
|||||||
#define OMV_ENABLE_LEPTON (0)
|
#define OMV_ENABLE_LEPTON (0)
|
||||||
#define OMV_ENABLE_HM01B0 (0)
|
#define OMV_ENABLE_HM01B0 (0)
|
||||||
#define OMV_ENABLE_PAJ6100 (0)
|
#define OMV_ENABLE_PAJ6100 (0)
|
||||||
|
#define OMV_ENABLE_FROGEYE2020 (0)
|
||||||
|
|
||||||
// Enable sensor features
|
// Enable sensor features
|
||||||
#define OMV_ENABLE_OV5640_AF (1)
|
#define OMV_ENABLE_OV5640_AF (1)
|
||||||
|
|||||||
@ -22,6 +22,7 @@
|
|||||||
#define LEPTON_SLV_ADDR (0x54)
|
#define LEPTON_SLV_ADDR (0x54)
|
||||||
#define HM01B0_SLV_ADDR (0x48)
|
#define HM01B0_SLV_ADDR (0x48)
|
||||||
#define GC2145_SLV_ADDR (0x78)
|
#define GC2145_SLV_ADDR (0x78)
|
||||||
|
#define FROGEYE2020_SLV_ADDR (0x6E)
|
||||||
|
|
||||||
// Chip ID Registers
|
// Chip ID Registers
|
||||||
#define OV5640_CHIP_ID (0x300A)
|
#define OV5640_CHIP_ID (0x300A)
|
||||||
@ -44,6 +45,7 @@
|
|||||||
#define GC2145_ID (0x21)
|
#define GC2145_ID (0x21)
|
||||||
// Wide ID
|
// Wide ID
|
||||||
#define PAJ6100_ID (0x6100)
|
#define PAJ6100_ID (0x6100)
|
||||||
|
#define FROGEYE2020_ID (0x2020)
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
FRAMESIZE_INVALID = 0,
|
FRAMESIZE_INVALID = 0,
|
||||||
|
|||||||
@ -27,6 +27,7 @@
|
|||||||
#include "lepton.h"
|
#include "lepton.h"
|
||||||
#include "hm01b0.h"
|
#include "hm01b0.h"
|
||||||
#include "paj6100.h"
|
#include "paj6100.h"
|
||||||
|
#include "frogeye2020.h"
|
||||||
#include "gc2145.h"
|
#include "gc2145.h"
|
||||||
#include "framebuffer.h"
|
#include "framebuffer.h"
|
||||||
#include "omv_boardconfig.h"
|
#include "omv_boardconfig.h"
|
||||||
@ -156,13 +157,9 @@ __weak int sensor_reset()
|
|||||||
// Re-enable the bus.
|
// Re-enable the bus.
|
||||||
cambus_enable(&sensor.bus, true);
|
cambus_enable(&sensor.bus, true);
|
||||||
|
|
||||||
// Check if the control is supported.
|
|
||||||
if (sensor.reset == NULL) {
|
|
||||||
return SENSOR_ERROR_CTL_UNSUPPORTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Call sensor-specific reset function
|
// Call sensor-specific reset function
|
||||||
if (sensor.reset(&sensor) != 0) {
|
if (sensor.reset != NULL
|
||||||
|
&& sensor.reset(&sensor) != 0) {
|
||||||
return SENSOR_ERROR_CTL_FAILED;
|
return SENSOR_ERROR_CTL_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,6 +283,14 @@ int sensor_probe_init(uint32_t bus_id, uint32_t bus_speed)
|
|||||||
break;
|
break;
|
||||||
#endif //(OMV_ENABLE_GC2145 == 1)
|
#endif //(OMV_ENABLE_GC2145 == 1)
|
||||||
|
|
||||||
|
#if (OMV_ENABLE_FROGEYE2020 == 1)
|
||||||
|
case FROGEYE2020_SLV_ADDR:
|
||||||
|
sensor.chip_id_w = FROGEYE2020_ID;
|
||||||
|
sensor.pwdn_pol = ACTIVE_HIGH;
|
||||||
|
sensor.reset_pol = ACTIVE_HIGH;
|
||||||
|
break;
|
||||||
|
#endif // (OMV_ENABLE_FROGEYE2020 == 1)
|
||||||
|
|
||||||
#if (OMV_ENABLE_PAJ6100 == 1)
|
#if (OMV_ENABLE_PAJ6100 == 1)
|
||||||
case 0:
|
case 0:
|
||||||
if (paj6100_detect(&sensor)) {
|
if (paj6100_detect(&sensor)) {
|
||||||
@ -403,6 +408,15 @@ int sensor_probe_init(uint32_t bus_id, uint32_t bus_speed)
|
|||||||
break;
|
break;
|
||||||
#endif // (OMV_ENABLE_PAJ6100 == 1)
|
#endif // (OMV_ENABLE_PAJ6100 == 1)
|
||||||
|
|
||||||
|
#if (OMV_ENABLE_FROGEYE2020 == 1)
|
||||||
|
case FROGEYE2020_ID:
|
||||||
|
if (sensor_set_xclk_frequency(FROGEYE2020_XCLK_FREQ) != 0) {
|
||||||
|
return SENSOR_ERROR_TIM_INIT_FAILED;
|
||||||
|
}
|
||||||
|
init_ret = frogeye2020_init(&sensor);
|
||||||
|
break;
|
||||||
|
#endif // (OMV_ENABLE_FROGEYE2020 == 1)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return SENSOR_ERROR_ISC_UNSUPPORTED;
|
return SENSOR_ERROR_ISC_UNSUPPORTED;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -757,8 +757,8 @@ static void imlib_erode_dilate(image_t *img, int ksize, int threshold, int e_or_
|
|||||||
for (int j = -ksize; j <= ksize; j++) {
|
for (int j = -ksize; j <= ksize; j++) {
|
||||||
uint8_t *k_row_ptr = IMAGE_COMPUTE_GRAYSCALE_PIXEL_ROW_PTR(img,y+j);
|
uint8_t *k_row_ptr = IMAGE_COMPUTE_GRAYSCALE_PIXEL_ROW_PTR(img,y+j);
|
||||||
// subtract old left edge and add new right edge to sum
|
// subtract old left edge and add new right edge to sum
|
||||||
acc -= (IMAGE_GET_GRAYSCALE_PIXEL_FAST(k_row_ptr,x-ksize-1) & 1); // values have already been thresholded to 0x00 or 0xFF
|
acc -= (IMAGE_GET_GRAYSCALE_PIXEL_FAST(k_row_ptr,x-ksize-1) > 0);
|
||||||
acc += (IMAGE_GET_GRAYSCALE_PIXEL_FAST(k_row_ptr,x+ksize) & 1);
|
acc += (IMAGE_GET_GRAYSCALE_PIXEL_FAST(k_row_ptr,x+ksize) > 0);
|
||||||
} // for j
|
} // for j
|
||||||
} else { // slower way which checks boundaries per pixel
|
} else { // slower way which checks boundaries per pixel
|
||||||
acc = e_or_d ? 0 : -1; // Don't count center pixel...
|
acc = e_or_d ? 0 : -1; // Don't count center pixel...
|
||||||
@ -767,8 +767,8 @@ static void imlib_erode_dilate(image_t *img, int ksize, int threshold, int e_or_
|
|||||||
IM_MIN(IM_MAX(y + j, 0), (img->h - 1)));
|
IM_MIN(IM_MAX(y + j, 0), (img->h - 1)));
|
||||||
|
|
||||||
for (int k = -ksize; k <= ksize; k++) {
|
for (int k = -ksize; k <= ksize; k++) {
|
||||||
acc += ((IMAGE_GET_GRAYSCALE_PIXEL_FAST(k_row_ptr,
|
acc += (IMAGE_GET_GRAYSCALE_PIXEL_FAST(k_row_ptr,
|
||||||
IM_MIN(IM_MAX(x + k, 0), (img->w - 1)))) >> 7);
|
IM_MIN(IM_MAX(x + k, 0), (img->w - 1)))) > 0;
|
||||||
} // for k
|
} // for k
|
||||||
} // for j
|
} // for j
|
||||||
}
|
}
|
||||||
@ -821,8 +821,8 @@ static void imlib_erode_dilate(image_t *img, int ksize, int threshold, int e_or_
|
|||||||
for (int j = -ksize; j <= ksize; j++) {
|
for (int j = -ksize; j <= ksize; j++) {
|
||||||
uint16_t *k_row_ptr = IMAGE_COMPUTE_RGB565_PIXEL_ROW_PTR(img,y+j);
|
uint16_t *k_row_ptr = IMAGE_COMPUTE_RGB565_PIXEL_ROW_PTR(img,y+j);
|
||||||
// subtract old left column and add new right column
|
// subtract old left column and add new right column
|
||||||
acc -= IMAGE_GET_RGB565_PIXEL_FAST(k_row_ptr,x-ksize-1) & 1; // already 0 or FFFF
|
acc -= IMAGE_GET_RGB565_PIXEL_FAST(k_row_ptr,x-ksize-1) > 0;
|
||||||
acc += IMAGE_GET_RGB565_PIXEL_FAST(k_row_ptr,x+ksize) & 1; // (pre-thresholded)
|
acc += IMAGE_GET_RGB565_PIXEL_FAST(k_row_ptr,x+ksize) > 0;
|
||||||
}
|
}
|
||||||
} else { // need to check boundary conditions for each pixel
|
} else { // need to check boundary conditions for each pixel
|
||||||
acc = e_or_d ? 0 : -1; // Don't count center pixel...
|
acc = e_or_d ? 0 : -1; // Don't count center pixel...
|
||||||
@ -832,7 +832,7 @@ static void imlib_erode_dilate(image_t *img, int ksize, int threshold, int e_or_
|
|||||||
|
|
||||||
for (int k = -ksize; k <= ksize; k++) {
|
for (int k = -ksize; k <= ksize; k++) {
|
||||||
acc += (IMAGE_GET_RGB565_PIXEL_FAST(k_row_ptr,
|
acc += (IMAGE_GET_RGB565_PIXEL_FAST(k_row_ptr,
|
||||||
IM_MIN(IM_MAX(x + k, 0), (img->w - 1)))) & 1; // already 0 or FFFF
|
IM_MIN(IM_MAX(x + k, 0), (img->w - 1)))) > 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -156,6 +156,7 @@ FIRM_OBJ += $(addprefix $(BUILD)/$(OMV_DIR)/sensors/, \
|
|||||||
hm01b0.o \
|
hm01b0.o \
|
||||||
gc2145.o \
|
gc2145.o \
|
||||||
paj6100.o \
|
paj6100.o \
|
||||||
|
frogeye2020.o \
|
||||||
)
|
)
|
||||||
|
|
||||||
FIRM_OBJ += $(addprefix $(BUILD)/$(OMV_DIR)/imlib/, \
|
FIRM_OBJ += $(addprefix $(BUILD)/$(OMV_DIR)/imlib/, \
|
||||||
@ -513,6 +514,7 @@ UVC_OBJ += $(addprefix $(BUILD)/$(OMV_DIR)/sensors/, \
|
|||||||
hm01b0.o \
|
hm01b0.o \
|
||||||
gc2145.o \
|
gc2145.o \
|
||||||
paj6100.o \
|
paj6100.o \
|
||||||
|
frogeye2020.o \
|
||||||
)
|
)
|
||||||
|
|
||||||
UVC_OBJ += $(addprefix $(BUILD)/$(OMV_DIR)/imlib/,\
|
UVC_OBJ += $(addprefix $(BUILD)/$(OMV_DIR)/imlib/,\
|
||||||
|
|||||||
35
src/omv/sensors/frogeye2020.c
Normal file
35
src/omv/sensors/frogeye2020.c
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the OpenMV project.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013-2021 Ibrahim Abdelkader <iabdalkader@openmv.io>
|
||||||
|
* Copyright (c) 2013-2021 Kwabena W. Agyeman <kwagyeman@openmv.io>
|
||||||
|
*
|
||||||
|
* This work is licensed under the MIT license, see the file LICENSE for details.
|
||||||
|
*
|
||||||
|
* FrogEye2020 driver.
|
||||||
|
*/
|
||||||
|
#include "omv_boardconfig.h"
|
||||||
|
#if (OMV_ENABLE_FROGEYE2020 == 1)
|
||||||
|
|
||||||
|
#include "sensor.h"
|
||||||
|
|
||||||
|
static int set_pixformat(sensor_t *sensor, pixformat_t pixformat)
|
||||||
|
{
|
||||||
|
return (pixformat == PIXFORMAT_GRAYSCALE) ? 0 : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int set_framesize(sensor_t *sensor, framesize_t framesize)
|
||||||
|
{
|
||||||
|
return (framesize == FRAMESIZE_QVGA) ? 0 : -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int frogeye2020_init(sensor_t *sensor)
|
||||||
|
{
|
||||||
|
sensor->set_pixformat = set_pixformat;
|
||||||
|
sensor->set_framesize = set_framesize;
|
||||||
|
sensor->hw_flags.pixck = 1;
|
||||||
|
sensor->hw_flags.gs_bpp = 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // (OMV_ENABLE_FROGEYE2020 == 1)
|
||||||
15
src/omv/sensors/frogeye2020.h
Normal file
15
src/omv/sensors/frogeye2020.h
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the OpenMV project.
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013-2021 Ibrahim Abdelkader <iabdalkader@openmv.io>
|
||||||
|
* Copyright (c) 2013-2021 Kwabena W. Agyeman <kwagyeman@openmv.io>
|
||||||
|
*
|
||||||
|
* This work is licensed under the MIT license, see the file LICENSE for details.
|
||||||
|
*
|
||||||
|
* FrogEye2020 driver.
|
||||||
|
*/
|
||||||
|
#ifndef __FROGEYE2020_H__
|
||||||
|
#define __FROGEYE2020_H__
|
||||||
|
#define FROGEYE2020_XCLK_FREQ (5000000)
|
||||||
|
int frogeye2020_init(sensor_t *sensor);
|
||||||
|
#endif // __FROGEYE2020_H__
|
||||||
Loading…
Reference in New Issue
Block a user