mirror of
https://github.com/openmv/openmv.git
synced 2025-09-26 23:09:13 +08:00
Merge pull request #2803 from openmv/add_post_process
Some checks are pending
🔥 Firmware Build / build-firmware (ARDUINO_GIGA) (push) Waiting to run
🔥 Firmware Build / build-firmware (ARDUINO_NANO_33_BLE_SENSE) (push) Waiting to run
🔥 Firmware Build / build-firmware (ARDUINO_NANO_RP2040_CONNECT) (push) Waiting to run
🔥 Firmware Build / build-firmware (ARDUINO_NICLA_VISION) (push) Waiting to run
🔥 Firmware Build / build-firmware (ARDUINO_PORTENTA_H7) (push) Waiting to run
🔥 Firmware Build / build-firmware (DOCKER) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV2) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV3) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV4) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV4P) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMVPT) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV_AE3) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV_N6) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV_RT1060) (push) Waiting to run
🔥 Firmware Build / code-size-report (push) Blocked by required conditions
🔥 Firmware Build / stable-release (push) Blocked by required conditions
🔥 Firmware Build / development-release (push) Blocked by required conditions
Some checks are pending
🔥 Firmware Build / build-firmware (ARDUINO_GIGA) (push) Waiting to run
🔥 Firmware Build / build-firmware (ARDUINO_NANO_33_BLE_SENSE) (push) Waiting to run
🔥 Firmware Build / build-firmware (ARDUINO_NANO_RP2040_CONNECT) (push) Waiting to run
🔥 Firmware Build / build-firmware (ARDUINO_NICLA_VISION) (push) Waiting to run
🔥 Firmware Build / build-firmware (ARDUINO_PORTENTA_H7) (push) Waiting to run
🔥 Firmware Build / build-firmware (DOCKER) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV2) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV3) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV4) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV4P) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMVPT) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV_AE3) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV_N6) (push) Waiting to run
🔥 Firmware Build / build-firmware (OPENMV_RT1060) (push) Waiting to run
🔥 Firmware Build / code-size-report (push) Blocked by required conditions
🔥 Firmware Build / stable-release (push) Blocked by required conditions
🔥 Firmware Build / development-release (push) Blocked by required conditions
common/csi: Add post process op.
This commit is contained in:
commit
5ccdebddf9
@ -1339,7 +1339,7 @@ __weak int omv_csi_set_lens_correction(omv_csi_t *csi, int enable, int radi, int
|
||||
|
||||
__weak int omv_csi_ioctl(omv_csi_t *csi, int request, ... /* arg */) {
|
||||
// Disable any ongoing frame capture.
|
||||
if (request & OMV_CSI_IOCTL_FLAGS_ABORT) {
|
||||
if (request & OMV_CSI_FLAG_IOCTL_ABORT) {
|
||||
omv_csi_abort(csi, true, false);
|
||||
}
|
||||
|
||||
@ -1580,7 +1580,7 @@ __weak int omv_csi_snapshot(omv_csi_t *csi, image_t *image, uint32_t flags) {
|
||||
// Note: We must check if the buffer has been used before releasing it,
|
||||
// as it might have been captured in non-blocking mode but not used yet.
|
||||
if (buffer && (buffer->flags & VB_FLAG_USED)) {
|
||||
if (flags & OMV_CSI_CAPTURE_FLAGS_UPDATE) {
|
||||
if (flags & OMV_CSI_FLAG_UPDATE_FB) {
|
||||
image_t tmp;
|
||||
framebuffer_init_image(csi->fb, &tmp);
|
||||
framebuffer_update_jpeg_buffer(&tmp);
|
||||
@ -1607,6 +1607,11 @@ __weak int omv_csi_snapshot(omv_csi_t *csi, image_t *image, uint32_t flags) {
|
||||
}
|
||||
#endif
|
||||
|
||||
// Call the sensor specific post-process.
|
||||
if (ret == 0 && csi->post_process && !(flags & OMV_CSI_FLAG_NO_POST)) {
|
||||
ret = csi->post_process(csi, image, flags);
|
||||
}
|
||||
|
||||
if (ret == 0) {
|
||||
// Mark this buffer to be released on the next call.
|
||||
buffer = framebuffer_acquire(csi->fb, FB_FLAG_USED | FB_FLAG_PEEK);
|
||||
|
@ -192,16 +192,14 @@ typedef enum {
|
||||
} omv_csi_framesize_t;
|
||||
|
||||
typedef enum {
|
||||
OMV_CSI_IOCTL_FLAGS_ABORT = (1 << 8),
|
||||
} omv_csi_ioctl_flags_t;
|
||||
OMV_CSI_FLAG_UPDATE_FB = (1 << 0),
|
||||
OMV_CSI_FLAG_NON_BLOCK = (1 << 1),
|
||||
OMV_CSI_FLAG_NO_POST = (1 << 2),
|
||||
OMV_CSI_FLAG_IOCTL_ABORT = (1 << 8),
|
||||
} omv_csi_flags_t;
|
||||
|
||||
typedef enum {
|
||||
OMV_CSI_CAPTURE_FLAGS_UPDATE = (1 << 0),
|
||||
OMV_CSI_CAPTURE_FLAGS_NBLOCK = (1 << 1),
|
||||
} omv_csi_capture_flags_t;
|
||||
|
||||
typedef enum {
|
||||
OMV_CSI_IOCTL_SET_READOUT_WINDOW = 0x00 | OMV_CSI_IOCTL_FLAGS_ABORT,
|
||||
OMV_CSI_IOCTL_SET_READOUT_WINDOW = 0x00 | OMV_CSI_FLAG_IOCTL_ABORT,
|
||||
OMV_CSI_IOCTL_GET_READOUT_WINDOW = 0x01,
|
||||
OMV_CSI_IOCTL_SET_TRIGGERED_MODE = 0x02,
|
||||
OMV_CSI_IOCTL_GET_TRIGGERED_MODE = 0x03,
|
||||
@ -223,15 +221,15 @@ typedef enum {
|
||||
OMV_CSI_IOCTL_LEPTON_GET_ATTRIBUTE = 0x13,
|
||||
OMV_CSI_IOCTL_LEPTON_GET_FPA_TEMP = 0x14,
|
||||
OMV_CSI_IOCTL_LEPTON_GET_AUX_TEMP = 0x15,
|
||||
OMV_CSI_IOCTL_LEPTON_SET_MODE = 0x16 | OMV_CSI_IOCTL_FLAGS_ABORT,
|
||||
OMV_CSI_IOCTL_LEPTON_SET_MODE = 0x16 | OMV_CSI_FLAG_IOCTL_ABORT,
|
||||
OMV_CSI_IOCTL_LEPTON_GET_MODE = 0x17,
|
||||
OMV_CSI_IOCTL_LEPTON_SET_RANGE = 0x18 | OMV_CSI_IOCTL_FLAGS_ABORT,
|
||||
OMV_CSI_IOCTL_LEPTON_SET_RANGE = 0x18 | OMV_CSI_FLAG_IOCTL_ABORT,
|
||||
OMV_CSI_IOCTL_LEPTON_GET_RANGE = 0x19,
|
||||
OMV_CSI_IOCTL_HIMAX_MD_ENABLE = 0x1A,
|
||||
OMV_CSI_IOCTL_HIMAX_MD_CLEAR = 0x1B,
|
||||
OMV_CSI_IOCTL_HIMAX_MD_WINDOW = 0x1C | OMV_CSI_IOCTL_FLAGS_ABORT,
|
||||
OMV_CSI_IOCTL_HIMAX_MD_WINDOW = 0x1C | OMV_CSI_FLAG_IOCTL_ABORT,
|
||||
OMV_CSI_IOCTL_HIMAX_MD_THRESHOLD = 0x1D,
|
||||
OMV_CSI_IOCTL_HIMAX_OSC_ENABLE = 0x1E | OMV_CSI_IOCTL_FLAGS_ABORT,
|
||||
OMV_CSI_IOCTL_HIMAX_OSC_ENABLE = 0x1E | OMV_CSI_FLAG_IOCTL_ABORT,
|
||||
OMV_CSI_IOCTL_GET_RGB_STATS = 0x1F,
|
||||
OMV_CSI_IOCTL_GENX320_SET_BIASES = 0x20,
|
||||
OMV_CSI_IOCTL_GENX320_SET_BIAS = 0x21,
|
||||
@ -292,6 +290,9 @@ typedef struct _omv_csi_callback_t {
|
||||
typedef int (*omv_csi_snapshot_t)
|
||||
(omv_csi_t *csi, image_t *image, uint32_t flags);
|
||||
|
||||
typedef int (*omv_csi_post_process_t)
|
||||
(omv_csi_t *csi, image_t *image, uint32_t flags);
|
||||
|
||||
typedef struct _omv_clk omv_clk_t;
|
||||
|
||||
typedef struct _omv_clk {
|
||||
@ -401,6 +402,7 @@ typedef struct _omv_csi {
|
||||
int (*config) (omv_csi_t *csi, omv_csi_config_t config);
|
||||
int (*abort) (omv_csi_t *csi, bool fifo_flush, bool in_irq);
|
||||
int (*snapshot) (omv_csi_t *csi, image_t *image, uint32_t flags);
|
||||
int (*post_process) (omv_csi_t *csi, image_t *image, uint32_t flags);
|
||||
} omv_csi_t;
|
||||
|
||||
// CSI array
|
||||
|
@ -416,7 +416,7 @@ static int snapshot(omv_csi_t *csi, image_t *image, uint32_t flags) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (flags & OMV_CSI_CAPTURE_FLAGS_NBLOCK) {
|
||||
if (flags & OMV_CSI_FLAG_NON_BLOCK) {
|
||||
return OMV_CSI_ERROR_WOULD_BLOCK;
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ static mp_obj_t py_omv_csi_snapshot(size_t n_args, const mp_obj_t *args, mp_map_
|
||||
#endif // MICROPY_PY_IMU
|
||||
|
||||
mp_obj_t image = py_image(0, 0, 0, 0, 0);
|
||||
uint32_t flags = OMV_CSI_CAPTURE_FLAGS_UPDATE;
|
||||
uint32_t flags = OMV_CSI_FLAG_UPDATE_FB;
|
||||
|
||||
int error = omv_csi_snapshot(csi, (image_t *) py_image_cobj(image), flags);
|
||||
if (error != 0) {
|
||||
|
@ -202,18 +202,18 @@ static mp_obj_t py_csi_snapshot(size_t n_args, const mp_obj_t *pos_args, mp_map_
|
||||
mp_int_t frames = args[ARG_frames].u_int;
|
||||
|
||||
if (args[ARG_update].u_bool) {
|
||||
flags |= OMV_CSI_CAPTURE_FLAGS_UPDATE;
|
||||
flags |= OMV_CSI_FLAG_UPDATE_FB;
|
||||
}
|
||||
|
||||
if (!args[ARG_blocking].u_bool) {
|
||||
flags |= OMV_CSI_CAPTURE_FLAGS_NBLOCK;
|
||||
flags |= OMV_CSI_FLAG_NON_BLOCK;
|
||||
}
|
||||
|
||||
if (time == -1 && frames == -1) {
|
||||
int error = omv_csi_snapshot(self->csi, &image, flags);
|
||||
if (error != 0) {
|
||||
if (error == OMV_CSI_ERROR_WOULD_BLOCK &&
|
||||
(flags & OMV_CSI_CAPTURE_FLAGS_NBLOCK)) {
|
||||
(flags & OMV_CSI_FLAG_NON_BLOCK)) {
|
||||
return mp_const_none;
|
||||
}
|
||||
omv_csi_raise_error(error);
|
||||
|
@ -310,7 +310,7 @@ int alif_csi_snapshot(omv_csi_t *csi, image_t *dst_image, uint32_t flags) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (flags & OMV_CSI_CAPTURE_FLAGS_NBLOCK) {
|
||||
if (flags & OMV_CSI_FLAG_NON_BLOCK) {
|
||||
return OMV_CSI_ERROR_WOULD_BLOCK;
|
||||
}
|
||||
|
||||
|
@ -394,7 +394,7 @@ int imx_csi_snapshot(omv_csi_t *csi, image_t *image, uint32_t flags) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (flags & OMV_CSI_CAPTURE_FLAGS_NBLOCK) {
|
||||
if (flags & OMV_CSI_FLAG_NON_BLOCK) {
|
||||
return OMV_CSI_ERROR_WOULD_BLOCK;
|
||||
}
|
||||
|
||||
|
@ -208,7 +208,7 @@ static int rp2_csi_snapshot(omv_csi_t *csi, image_t *image, uint32_t flags) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (flags & OMV_CSI_CAPTURE_FLAGS_NBLOCK) {
|
||||
if (flags & OMV_CSI_FLAG_NON_BLOCK) {
|
||||
return OMV_CSI_ERROR_WOULD_BLOCK;
|
||||
}
|
||||
|
||||
|
@ -640,7 +640,7 @@ static int stm_csi_snapshot(omv_csi_t *csi, image_t *image, uint32_t flags) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (flags & OMV_CSI_CAPTURE_FLAGS_NBLOCK) {
|
||||
if (flags & OMV_CSI_FLAG_NON_BLOCK) {
|
||||
return OMV_CSI_ERROR_WOULD_BLOCK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user