File tree Expand file tree Collapse file tree 2 files changed +6
-4
lines changed
internal_filesystem/apps/com.example.camtest/assets Expand file tree Collapse file tree 2 files changed +6
-4
lines changed Original file line number Diff line number Diff line change 1111#include "py/runtime.h"
1212#include "py/mperrno.h"
1313
14+ // Forward declaration of the webcam type
15+ static const mp_obj_type_t webcam_type ;
16+
1417#define WIDTH 640
1518#define HEIGHT 480
1619#define NUM_BUFFERS 4
1720#define OUTPUT_WIDTH 240
1821#define OUTPUT_HEIGHT 240
1922
20- // Forward declaration of the webcam type
21- static const mp_obj_type_t webcam_type ;
22-
2323typedef struct _webcam_obj_t {
2424 mp_obj_base_t base ;
2525 int fd ;
@@ -178,7 +178,7 @@ static mp_obj_t capture_frame(webcam_obj_t *self) {
178178 snprintf (filename , sizeof (filename ), "frame_%03d.raw" , self -> frame_count ++ );
179179 save_raw (filename , self -> gray_buffer , OUTPUT_WIDTH , OUTPUT_HEIGHT );
180180
181- mp_obj_t result = mp_obj_new_bytes ( self -> gray_buffer , OUTPUT_WIDTH * OUTPUT_HEIGHT );
181+ mp_obj_t result = mp_obj_new_memoryview ( 0x01 , OUTPUT_WIDTH * OUTPUT_HEIGHT , self -> gray_buffer );
182182
183183 if (ioctl (self -> fd , VIDIOC_QBUF , & buf ) < 0 ) {
184184 mp_raise_OSError (MP_EIO );
Original file line number Diff line number Diff line change @@ -110,6 +110,8 @@ def try_capture():
110110 webcam .free_buffer (cam ) # Explicitly free webcam buffer
111111 else :
112112 cam .free_buffer () # Free other camera buffer
113+ else :
114+ print ("current_cam_buffer is None, not freeing..." )
113115 current_cam_buffer = new_cam_buffer # Store new buffer reference
114116 else :
115117 print ("Invalid buffer size:" , len (new_cam_buffer ))
You can’t perform that action at this time.
0 commit comments