Skip to content

Upate Camera support to reflect changes in API #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2025
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
20 changes: 11 additions & 9 deletions libraries/Camera/src/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ bool Camera::begin(uint32_t width, uint32_t height, uint32_t pixformat, bool byt
}

// Get capabilities
struct video_caps caps = {0};
if (video_get_caps(this->vdev, VIDEO_EP_OUT, &caps)) {
struct video_caps caps;
if (video_get_caps(this->vdev, &caps)) {
return false;
}

Expand All @@ -96,7 +96,7 @@ bool Camera::begin(uint32_t width, uint32_t height, uint32_t pixformat, bool byt
.pitch = width * 2,
};

if (video_set_format(this->vdev, VIDEO_EP_OUT, &fmt)) {
if (video_set_format(this->vdev, &fmt)) {
Serial.println("Failed to set video format");
return false;
}
Expand All @@ -110,11 +110,11 @@ bool Camera::begin(uint32_t width, uint32_t height, uint32_t pixformat, bool byt
Serial.println("Failed to allocate video buffers");
return false;
}
video_enqueue(this->vdev, VIDEO_EP_OUT, this->vbuf[i]);
video_enqueue(this->vdev, this->vbuf[i]);
}

// Start video capture
if (video_stream_start(this->vdev)) {
if (video_stream_start(this->vdev, VIDEO_BUF_TYPE_OUTPUT)) {
Serial.println("Failed to start capture");
return false;
}
Expand All @@ -127,7 +127,7 @@ bool Camera::grabFrame(FrameBuffer &fb, uint32_t timeout) {
return false;
}

if (video_dequeue(this->vdev, VIDEO_EP_OUT, &fb.vbuf, K_MSEC(timeout))) {
if (video_dequeue(this->vdev, &fb.vbuf, K_MSEC(timeout))) {
return false;
}

Expand All @@ -154,17 +154,19 @@ bool Camera::releaseFrame(FrameBuffer &fb) {
return false;
}

if (video_enqueue(this->vdev, VIDEO_EP_OUT, fb.vbuf)) {
if (video_enqueue(this->vdev, fb.vbuf)) {
return false;
}

return true;
}

bool Camera::setVerticalFlip(bool flip_enable) {
return video_set_ctrl(this->vdev, VIDEO_CID_VFLIP, (void *) flip_enable) == 0;
struct video_control ctrl = {.id = VIDEO_CID_VFLIP, .val = flip_enable};
return video_set_ctrl(this->vdev, &ctrl) == 0;
}

bool Camera::setHorizontalMirror(bool mirror_enable) {
return video_set_ctrl(this->vdev, VIDEO_CID_HFLIP, (void *) mirror_enable) == 0;
struct video_control ctrl = {.id = VIDEO_CID_HFLIP, .val = mirror_enable};
return video_set_ctrl(this->vdev, &ctrl) == 0;
}
1 change: 1 addition & 0 deletions loader/llext_exports.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ FORCE_EXPORT_SYM(__stack_chk_fail);
FORCE_EXPORT_SYM(video_buffer_aligned_alloc);
FORCE_EXPORT_SYM(video_buffer_alloc);
FORCE_EXPORT_SYM(video_buffer_release);
FORCE_EXPORT_SYM(video_set_ctrl);
#endif

#if defined(CONFIG_SHARED_MULTI_HEAP)
Expand Down