Skip to content

Commit 3225af7

Browse files
authored
Merge pull request #135 from mjs513/camera_library_update
Upate Camera support to reflect changes in API
2 parents 1b82c35 + 334d91c commit 3225af7

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

libraries/Camera/src/camera.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ bool Camera::begin(uint32_t width, uint32_t height, uint32_t pixformat, bool byt
7070
}
7171

7272
// Get capabilities
73-
struct video_caps caps = {0};
74-
if (video_get_caps(this->vdev, VIDEO_EP_OUT, &caps)) {
73+
struct video_caps caps;
74+
if (video_get_caps(this->vdev, &caps)) {
7575
return false;
7676
}
7777

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

99-
if (video_set_format(this->vdev, VIDEO_EP_OUT, &fmt)) {
99+
if (video_set_format(this->vdev, &fmt)) {
100100
Serial.println("Failed to set video format");
101101
return false;
102102
}
@@ -110,11 +110,11 @@ bool Camera::begin(uint32_t width, uint32_t height, uint32_t pixformat, bool byt
110110
Serial.println("Failed to allocate video buffers");
111111
return false;
112112
}
113-
video_enqueue(this->vdev, VIDEO_EP_OUT, this->vbuf[i]);
113+
video_enqueue(this->vdev, this->vbuf[i]);
114114
}
115115

116116
// Start video capture
117-
if (video_stream_start(this->vdev)) {
117+
if (video_stream_start(this->vdev, VIDEO_BUF_TYPE_OUTPUT)) {
118118
Serial.println("Failed to start capture");
119119
return false;
120120
}
@@ -127,7 +127,7 @@ bool Camera::grabFrame(FrameBuffer &fb, uint32_t timeout) {
127127
return false;
128128
}
129129

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

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

157-
if (video_enqueue(this->vdev, VIDEO_EP_OUT, fb.vbuf)) {
157+
if (video_enqueue(this->vdev, fb.vbuf)) {
158158
return false;
159159
}
160160

161161
return true;
162162
}
163163

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

168169
bool Camera::setHorizontalMirror(bool mirror_enable) {
169-
return video_set_ctrl(this->vdev, VIDEO_CID_HFLIP, (void *) mirror_enable) == 0;
170+
struct video_control ctrl = {.id = VIDEO_CID_HFLIP, .val = mirror_enable};
171+
return video_set_ctrl(this->vdev, &ctrl) == 0;
170172
}

loader/llext_exports.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ FORCE_EXPORT_SYM(__stack_chk_fail);
129129
FORCE_EXPORT_SYM(video_buffer_aligned_alloc);
130130
FORCE_EXPORT_SYM(video_buffer_alloc);
131131
FORCE_EXPORT_SYM(video_buffer_release);
132+
FORCE_EXPORT_SYM(video_set_ctrl);
132133
#endif
133134

134135
#if defined(CONFIG_SHARED_MULTI_HEAP)

0 commit comments

Comments
 (0)