From 5228c32c2195ad8050135141ce67057aea7a2d2a Mon Sep 17 00:00:00 2001 From: nihui Date: Fri, 8 Mar 2024 14:29:58 +0800 Subject: [PATCH] less verbose output for highgui hw info --- highgui/src/capture_cvi.cpp | 37 +++----------- highgui/src/capture_v4l2_aw_isp.cpp | 16 +++--- highgui/src/capture_v4l2_rk_aiq.cpp | 76 +++++++++++++++-------------- highgui/src/jpeg_decoder_aw.cpp | 27 +++------- highgui/src/jpeg_decoder_cvi.cpp | 33 +++---------- highgui/src/jpeg_encoder_aw.cpp | 28 +++-------- highgui/src/jpeg_encoder_rk_mpp.cpp | 57 +++++++++++++++------- 7 files changed, 109 insertions(+), 165 deletions(-) diff --git a/highgui/src/capture_cvi.cpp b/highgui/src/capture_cvi.cpp index 55d35c46..3a79ff06 100644 --- a/highgui/src/capture_cvi.cpp +++ b/highgui/src/capture_cvi.cpp @@ -84,35 +84,17 @@ static int get_device_model() } } + if (device_model > 0) + { + fprintf(stderr, "opencv-mobile MIPI CSI camera with cvi\n"); + } + return device_model; } static bool is_device_whitelisted() { - const int device_model = get_device_model(); - - if (device_model == 1) - { - // milkv duo - return true; - } - if (device_model == 2) - { - // milkv duo 256 - return true; - } - if (device_model == 3) - { - // licheerv nano - return true; - } - if (device_model == 4) - { - // milkv duo s - return true; - } - - return false; + return get_device_model() > 0; } extern "C" @@ -258,7 +240,6 @@ static int load_sys_library() bool whitelisted = is_device_whitelisted(); if (!whitelisted) { - fprintf(stderr, "this device is not whitelisted for capture cvi\n"); return -1; } @@ -975,7 +956,6 @@ static int load_vpu_library() bool whitelisted = is_device_whitelisted(); if (!whitelisted) { - fprintf(stderr, "this device is not whitelisted for capture cvi\n"); return -1; } @@ -1827,7 +1807,6 @@ static int load_sns_obj_library() bool whitelisted = is_device_whitelisted(); if (!whitelisted) { - fprintf(stderr, "this device is not whitelisted for capture cvi\n"); return -1; } @@ -2199,7 +2178,6 @@ static int load_ae_library() bool whitelisted = is_device_whitelisted(); if (!whitelisted) { - fprintf(stderr, "this device is not whitelisted for capture cvi\n"); return -1; } @@ -2266,7 +2244,6 @@ static int load_awb_library() bool whitelisted = is_device_whitelisted(); if (!whitelisted) { - fprintf(stderr, "this device is not whitelisted for capture cvi\n"); return -1; } @@ -2346,7 +2323,6 @@ static int load_isp_library() bool whitelisted = is_device_whitelisted(); if (!whitelisted) { - fprintf(stderr, "this device is not whitelisted for capture cvi\n"); return -1; } @@ -2454,7 +2430,6 @@ static int load_cvi_bin_library() bool whitelisted = is_device_whitelisted(); if (!whitelisted) { - fprintf(stderr, "this device is not whitelisted for capture cvi\n"); return -1; } diff --git a/highgui/src/capture_v4l2_aw_isp.cpp b/highgui/src/capture_v4l2_aw_isp.cpp index ed0c72c2..7b906028 100644 --- a/highgui/src/capture_v4l2_aw_isp.cpp +++ b/highgui/src/capture_v4l2_aw_isp.cpp @@ -65,20 +65,17 @@ static int get_device_model() } } + if (device_model > 0) + { + fprintf(stderr, "opencv-mobile MIPI CSI camera with v4l2 awispapi\n"); + } + return device_model; } static bool is_device_whitelisted() { - const int device_model = get_device_model(); - - if (device_model == 1) - { - // tinyvision - return true; - } - - return false; + return get_device_model() > 0; } extern "C" { @@ -415,7 +412,6 @@ static int load_awispapi_library() bool whitelisted = is_device_whitelisted(); if (!whitelisted) { - fprintf(stderr, "this device is not whitelisted for capture v4l2 awispapi\n"); return -1; } diff --git a/highgui/src/capture_v4l2_rk_aiq.cpp b/highgui/src/capture_v4l2_rk_aiq.cpp index 49d07918..d679a9ce 100644 --- a/highgui/src/capture_v4l2_rk_aiq.cpp +++ b/highgui/src/capture_v4l2_rk_aiq.cpp @@ -39,6 +39,44 @@ namespace cv { +// 0 = unknown +// 1 = luckfox-pico +static int get_device_model() +{ + static int device_model = -1; + + if (device_model >= 0) + return device_model; + + device_model = 0; + + FILE* fp = fopen("/proc/device-tree/model", "rb"); + if (fp) + { + char buf[1024]; + fgets(buf, 1024, fp); + fclose(fp); + + if (strncmp(buf, "Luckfox Pico", 12) == 0) + { + // luckfox pico family and plus pro max mini variants + device_model = 1; + } + } + + if (device_model > 0) + { + fprintf(stderr, "opencv-mobile MIPI CSI camera with v4l2 rkaiq\n"); + } + + return device_model; +} + +static bool is_device_whitelisted() +{ + return get_device_model() > 0; +} + extern "C" { @@ -348,26 +386,9 @@ static int load_rkaiq_library() return 0; // check device whitelist - bool whitelisted = false; - { - FILE* fp = fopen("/proc/device-tree/model", "rb"); - if (!fp) - return -1; - - char buf[1024]; - fgets(buf, 1024, fp); - fclose(fp); - - if (strncmp(buf, "Luckfox Pico", 12) == 0) - { - // luckfox pico family and plus pro max mini variants - whitelisted = true; - } - } - + bool whitelisted = is_device_whitelisted(); if (!whitelisted) { - fprintf(stderr, "this device is not whitelisted for capture v4l2 rkaiq\n"); return -1; } @@ -606,26 +627,9 @@ static int load_rga_library() return 0; // check device whitelist - bool whitelisted = false; - { - FILE* fp = fopen("/proc/device-tree/model", "rb"); - if (!fp) - return -1; - - char buf[1024]; - fgets(buf, 1024, fp); - fclose(fp); - - if (strncmp(buf, "Luckfox Pico", 12) == 0) - { - // luckfox pico family and plus pro max mini variants - whitelisted = true; - } - } - + bool whitelisted = is_device_whitelisted(); if (!whitelisted) { - fprintf(stderr, "this device is not whitelisted for capture v4l2 rkaiq\n"); return -1; } diff --git a/highgui/src/jpeg_decoder_aw.cpp b/highgui/src/jpeg_decoder_aw.cpp index 1021adaa..8447d9e5 100644 --- a/highgui/src/jpeg_decoder_aw.cpp +++ b/highgui/src/jpeg_decoder_aw.cpp @@ -75,30 +75,17 @@ static int get_device_model() } } + if (device_model > 0) + { + fprintf(stderr, "opencv-mobile HW JPG decoder with aw cedarc\n"); + } + return device_model; } static bool is_device_whitelisted() { - const int device_model = get_device_model(); - - if (device_model == 1) - { - // t113-i - return true; - } - if (device_model == 2) - { - // tinyvision - return true; - } - if (device_model == 3) - { - // yuzuki-chameleon - return true; - } - - return false; + return get_device_model() > 0; } extern "C" { @@ -143,7 +130,6 @@ static int load_videoengine_library() bool whitelisted = is_device_whitelisted(); if (!whitelisted) { - fprintf(stderr, "this device is not whitelisted for jpeg decoder aw cedarc\n"); return -1; } @@ -676,7 +662,6 @@ static int load_vdecoder_library() bool whitelisted = is_device_whitelisted(); if (!whitelisted) { - fprintf(stderr, "this device is not whitelisted for jpeg decoder aw cedarc\n"); return -1; } diff --git a/highgui/src/jpeg_decoder_cvi.cpp b/highgui/src/jpeg_decoder_cvi.cpp index 30815c28..206a8717 100644 --- a/highgui/src/jpeg_decoder_cvi.cpp +++ b/highgui/src/jpeg_decoder_cvi.cpp @@ -82,35 +82,17 @@ static int get_device_model() } } + if (device_model > 0) + { + fprintf(stderr, "opencv-mobile HW JPG decoder with cvi\n"); + } + return device_model; } static bool is_device_whitelisted() { - const int device_model = get_device_model(); - - if (device_model == 1) - { - // milkv duo - return true; - } - if (device_model == 2) - { - // milkv duo 256 - return true; - } - if (device_model == 3) - { - // licheerv nano - return true; - } - if (device_model == 4) - { - // milkv duo s - return true; - } - - return false; + return get_device_model() > 0; } extern "C" @@ -248,7 +230,6 @@ static int load_sys_library() bool whitelisted = is_device_whitelisted(); if (!whitelisted) { - fprintf(stderr, "this device is not whitelisted for jpeg decoder cvi\n"); return -1; } @@ -657,7 +638,6 @@ static int load_vdec_library() bool whitelisted = is_device_whitelisted(); if (!whitelisted) { - fprintf(stderr, "this device is not whitelisted for jpeg decoder cvi\n"); return -1; } @@ -925,7 +905,6 @@ static int load_vpu_library() bool whitelisted = is_device_whitelisted(); if (!whitelisted) { - fprintf(stderr, "this device is not whitelisted for jpeg decoder cvi\n"); return -1; } diff --git a/highgui/src/jpeg_encoder_aw.cpp b/highgui/src/jpeg_encoder_aw.cpp index c755189a..5fb6829a 100644 --- a/highgui/src/jpeg_encoder_aw.cpp +++ b/highgui/src/jpeg_encoder_aw.cpp @@ -74,35 +74,20 @@ static int get_device_model() } } + if (device_model > 0) + { + fprintf(stderr, "opencv-mobile HW JPG encoder with aw cedarc\n"); + } + return device_model; } static bool is_device_whitelisted() { - const int device_model = get_device_model(); - - if (device_model == 1) - { - // t113-i - return true; - } - if (device_model == 2) - { - // tinyvision - return true; - } - if (device_model == 3) - { - // yuzuki-chameleon - return true; - } - - return false; + return get_device_model() > 0; } - - extern "C" { typedef enum VENC_CODEC_TYPE { @@ -608,7 +593,6 @@ static int load_vencoder_library() bool whitelisted = is_device_whitelisted(); if (!whitelisted) { - fprintf(stderr, "this device is not whitelisted for jpeg encoder aw cedarc\n"); return -1; } diff --git a/highgui/src/jpeg_encoder_rk_mpp.cpp b/highgui/src/jpeg_encoder_rk_mpp.cpp index b5622f77..0e222552 100644 --- a/highgui/src/jpeg_encoder_rk_mpp.cpp +++ b/highgui/src/jpeg_encoder_rk_mpp.cpp @@ -37,6 +37,44 @@ namespace cv { +// 0 = unknown +// 1 = luckfox-pico +static int get_device_model() +{ + static int device_model = -1; + + if (device_model >= 0) + return device_model; + + device_model = 0; + + FILE* fp = fopen("/proc/device-tree/model", "rb"); + if (fp) + { + char buf[1024]; + fgets(buf, 1024, fp); + fclose(fp); + + if (strncmp(buf, "Luckfox Pico", 12) == 0) + { + // luckfox pico family and plus pro max mini variants + device_model = 1; + } + } + + if (device_model > 0) + { + fprintf(stderr, "opencv-mobile HW JPG encoder with rk mpp\n"); + } + + return device_model; +} + +static bool is_device_whitelisted() +{ + return get_device_model() > 0; +} + extern "C" { #define MPP_SUCCESS 0 @@ -197,26 +235,9 @@ static int load_rkmpp_library() return 0; // check device whitelist - bool whitelisted = false; - { - FILE* fp = fopen("/proc/device-tree/model", "rb"); - if (!fp) - return -1; - - char buf[1024]; - fgets(buf, 1024, fp); - fclose(fp); - - if (strncmp(buf, "Luckfox Pico", 12) == 0) - { - // luckfox pico family and plus pro max mini variants - whitelisted = true; - } - } - + bool whitelisted = is_device_whitelisted(); if (!whitelisted) { - fprintf(stderr, "this device is not whitelisted for jpeg encoder rkmpp\n"); return -1; }