Revert "MemoryView instead of bytes makes it worse?"

This reverts commit aabf8ed179.
This commit is contained in:
Thomas Farstrike
2025-05-14 11:38:42 +02:00
parent aabf8ed179
commit b89c251ca2
2 changed files with 4 additions and 6 deletions
+4 -4
View File
@@ -11,15 +11,15 @@
#include "py/runtime.h"
#include "py/mperrno.h"
// Forward declaration of the webcam type
static const mp_obj_type_t webcam_type;
#define WIDTH 640
#define HEIGHT 480
#define NUM_BUFFERS 4
#define OUTPUT_WIDTH 240
#define OUTPUT_HEIGHT 240
// Forward declaration of the webcam type
static const mp_obj_type_t webcam_type;
typedef struct _webcam_obj_t {
mp_obj_base_t base;
int fd;
@@ -178,7 +178,7 @@ static mp_obj_t capture_frame(webcam_obj_t *self) {
snprintf(filename, sizeof(filename), "frame_%03d.raw", self->frame_count++);
save_raw(filename, self->gray_buffer, OUTPUT_WIDTH, OUTPUT_HEIGHT);
mp_obj_t result = mp_obj_new_memoryview(0x01, OUTPUT_WIDTH * OUTPUT_HEIGHT, self->gray_buffer);
mp_obj_t result = mp_obj_new_bytes(self->gray_buffer, OUTPUT_WIDTH * OUTPUT_HEIGHT);
if (ioctl(self->fd, VIDIOC_QBUF, &buf) < 0) {
mp_raise_OSError(MP_EIO);
@@ -110,8 +110,6 @@ def try_capture():
webcam.free_buffer(cam) # Explicitly free webcam buffer
else:
cam.free_buffer() # Free other camera buffer
else:
print("current_cam_buffer is None, not freeing...")
current_cam_buffer = new_cam_buffer # Store new buffer reference
else:
print("Invalid buffer size:", len(new_cam_buffer))