* optimize vo

This commit is contained in:
lxowalle
2025-11-10 16:11:53 +08:00
parent ea00850a59
commit af752f3b5a
2 changed files with 29 additions and 1 deletions

View File

@@ -776,6 +776,12 @@ namespace maix::display
}
case image::FIT_COVER:
{
if (ALIGN_UP(img.width(),16) == img.width() && ALIGN_UP(img.height(),2) == img.height()) {
// fit success, use new frame
output_frame = input_frame;
input_frame = nullptr;
break;
}
float scale_x = (float)_width / input_frame->w;
float scale_y = (float)_height / input_frame->h;
float scale = (float)_width / _height;
@@ -824,6 +830,8 @@ namespace maix::display
}
default:
// do nothing, include image::FIT_FILL
output_frame = input_frame;
input_frame = nullptr;
break;
}

View File

@@ -22,6 +22,7 @@ static bool camera2_enable = false;
static bool disp2_enable = false;
static bool save_image_flag = false;
fp5510::FP5510 *g_fp5510e = nullptr;
static image::Fit g_fit = image::FIT_COVER;
static void __save_img(image::Image *img1, image::Image *img2 = nullptr) {
std::string suffix = ".rgb";
@@ -178,7 +179,7 @@ int _main(int argc, char* argv[])
// time when read image finished
t2 = time::ticks_ms();
disp.show(*img, image::FIT_COVER);
disp.show(*img, g_fit);
// free image data, important!
delete img;
@@ -241,6 +242,7 @@ static int cmd_init(void)
"20 <pos>: set fp5510e pos\r\n"
"21 : save camera img to file\r\n"
"22 : set white balance gain\r\n"
"23 : set fit, 0:FIT_FILL, 1:FIT_CONTAIN, 2:FIT_COVER\r\n"
"========================\r\n");
fflush(stdin);
return 0;
@@ -470,6 +472,24 @@ static int cmd_loop(camera::Camera *cam, display::Display *disp)
log::info("Get white balance gain to [%f, %f, %f, %f]", new_gains[0], new_gains[1], new_gains[2], new_gains[3]);
break;
}
case 23:
{
switch (value) {
case 0:
g_fit = image::FIT_FILL;
log::info("set fit mode: FIT_FILL");
break;
case 1:
g_fit = image::FIT_CONTAIN;
log::info("set fit mode: FIT_CONTAIN");
break;
default:
g_fit = image::FIT_COVER;
log::info("set fit mode: FIT_COVER");
break;
}
break;
}
default:printf("The command %d was not found!\r\n", cmd); break;
}