Skip to content

Commit

Permalink
less verbose output for highgui hw info
Browse files Browse the repository at this point in the history
  • Loading branch information
nihui committed Mar 8, 2024
1 parent 6e6eea7 commit 5228c32
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 165 deletions.
37 changes: 6 additions & 31 deletions highgui/src/capture_cvi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
16 changes: 6 additions & 10 deletions highgui/src/capture_v4l2_aw_isp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down Expand Up @@ -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;
}

Expand Down
76 changes: 40 additions & 36 deletions highgui/src/capture_v4l2_rk_aiq.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
{

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
27 changes: 6 additions & 21 deletions highgui/src/jpeg_decoder_aw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
33 changes: 6 additions & 27 deletions highgui/src/jpeg_decoder_cvi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
}

Expand Down
Loading

0 comments on commit 5228c32

Please sign in to comment.