Skip to content
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
4 changes: 0 additions & 4 deletions main/pages/capture_entropy.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,9 @@ static const char *TAG = "capture_entropy";
#define CAMERA_INPUT_WIDTH 1280
#define CAMERA_INPUT_HEIGHT 960
#define CAMERA_INPUT_CROP CAMERA_INPUT_HEIGHT
#define CAMERA_INPUT_CROP_OFFSET_X \
((CAMERA_INPUT_WIDTH - CAMERA_INPUT_CROP) / 2)
#define CAMERA_INPUT_CROP_OFFSET_Y 0
#define CAMERA_DIM_MIN \
((BSP_LCD_H_RES) < (BSP_LCD_V_RES) ? (BSP_LCD_H_RES) : (BSP_LCD_V_RES))
#define CAMERA_PPA_FRAG ((CAMERA_DIM_MIN * 16) / CAMERA_INPUT_CROP)
#define CAMERA_PPA_SCALE ((float)CAMERA_PPA_FRAG / 16.0f)
#define CAMERA_SIZE ((CAMERA_INPUT_CROP * CAMERA_PPA_FRAG) / 16)
#define CAMERA_WIDTH CAMERA_SIZE
#define CAMERA_HEIGHT CAMERA_SIZE
Expand Down
16 changes: 11 additions & 5 deletions main/qr/scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,8 @@
#define CAMERA_INPUT_HEIGHT 960
#define CAMERA_INPUT_CROP \
((CAMERA_TARGET * 2 <= 960) ? (CAMERA_TARGET * 2) : 960)
#define CAMERA_INPUT_CROP_OFFSET_X \
((CAMERA_INPUT_WIDTH - CAMERA_INPUT_CROP) / 2)
#define CAMERA_INPUT_CROP_OFFSET_Y \
((CAMERA_INPUT_HEIGHT - CAMERA_INPUT_CROP) / 2)
// Largest Q4.4 scale <= target/crop, and the exact preview size it yields.
#define CAMERA_PPA_FRAG ((CAMERA_TARGET * 16) / CAMERA_INPUT_CROP)
#define CAMERA_PPA_SCALE ((float)CAMERA_PPA_FRAG / 16.0f)
#define CAMERA_SCREEN_SIZE ((CAMERA_INPUT_CROP * CAMERA_PPA_FRAG) / 16)
#define CAMERA_SCREEN_WIDTH CAMERA_SCREEN_SIZE
#define CAMERA_SCREEN_HEIGHT CAMERA_SCREEN_SIZE
Expand Down Expand Up @@ -812,6 +807,17 @@ static void camera_video_frame_operation(uint8_t *camera_buf,
return;
}

static bool resolution_mismatch_logged = false;
if (!resolution_mismatch_logged && (camera_buf_hes != CAMERA_INPUT_WIDTH ||
camera_buf_ves != CAMERA_INPUT_HEIGHT)) {
ESP_LOGW(TAG,
"Camera resolution %" PRIu32 "x%" PRIu32
" differs from expected %dx%d; cropping dynamically",
camera_buf_hes, camera_buf_ves, CAMERA_INPUT_WIDTH,
CAMERA_INPUT_HEIGHT);
resolution_mismatch_logged = true;
}

uint8_t *back_buffer = (current_display_buffer == display_buffer_a)
? display_buffer_b
: display_buffer_a;
Expand Down
4 changes: 4 additions & 0 deletions simulator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ if(SIM_WEBCAM)
${COREVIDEO_FRAMEWORK}
${FOUNDATION_FRAMEWORK}
)
set_source_files_properties(
${CMAKE_CURRENT_SOURCE_DIR}/platform/video_sim/v4l2_capture_macos.mm
PROPERTIES COMPILE_FLAGS "-fobjc-arc"
)
else()
add_library(v4l2_capture STATIC
${CMAKE_CURRENT_SOURCE_DIR}/platform/video_sim/v4l2_capture.c
Expand Down
5 changes: 3 additions & 2 deletions simulator/platform/video_sim/v4l2_capture_macos.mm
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ - (void)captureOutput:(AVCaptureOutput *)output
static bool parse_device_index(const char *device, int *out_index) {
if (!device || !out_index)
return false;
if (strncmp(device, "/dev/video", 9) == 0) {
device += 9;
if (strncmp(device, "/dev/video", 10) == 0) {
device += 10;
}
char *end = NULL;
long idx = strtol(device, &end, 10);
Expand Down Expand Up @@ -292,6 +292,7 @@ void v4l2_capture_close(v4l2_capture_t *cap) {
}
cap->output = nil;
cap->delegate = nil;
cap->queue = nil;

free(cap->rgb565);
cap->rgb565 = NULL;
Expand Down
Loading