Skip to content

Commit

Permalink
* optimize vi
Browse files Browse the repository at this point in the history
  • Loading branch information
lxowalle committed Aug 12, 2024
1 parent 1a91713 commit a661491
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
8 changes: 3 additions & 5 deletions components/vision/port/maixcam/maix_camera_mmf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,16 +358,14 @@ namespace maix::camera
sys_cfg.vb_pool[0].count = 3;
sys_cfg.vb_pool[0].map = 2;
sys_cfg.max_pool_cnt = 1;

stIniCfg.enSnsType[0] = GCORE_GC4653_MIPI_720P_60FPS_10BIT;
} else {
sys_cfg.vb_pool[0].size = 2560 * 1440 * 3 / 2;
sys_cfg.vb_pool[0].count = 2;
sys_cfg.vb_pool[0].map = 2;
sys_cfg.max_pool_cnt = 1;
}

if (width <= 1280 && height <= 720 && fps > 30) {
stIniCfg.enSnsType[0] = GCORE_GC4653_MIPI_720P_60FPS_10BIT;
} else {
stIniCfg.enSnsType[0] = GCORE_GC4653_MIPI_4M_30FPS_10BIT;
}
stIniCfg.as8PNSwap[0][0] = 0;
Expand Down Expand Up @@ -452,7 +450,7 @@ namespace maix::camera
// mmf init
err::check_bool_raise(!_mmf_vi_init(_width, _height, _fps), "mmf vi init failed");
err::check_bool_raise((_ch = mmf_get_vi_unused_channel()) >= 0, "mmf get vi channel failed");
if (0 != mmf_add_vi_channel_v2(_ch, _width, _height, mmf_invert_format_to_mmf(_format_impl), _fps, 2, -1, -1, 2, 3)) {
if (0 != mmf_add_vi_channel_v2(_ch, _width, _height, mmf_invert_format_to_mmf(_format_impl), _fps, _buff_num, -1, -1, 2, _buff_num)) {
mmf_vi_deinit();
mmf_deinit_v2(false);
err::check_raise(err::ERR_RUNTIME, "mmf add vi channel failed");
Expand Down
22 changes: 21 additions & 1 deletion examples/jpg_stream_demo/main/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,27 @@ extern std::string html;

int _main(int argc, char* argv[])
{
camera::Camera cam = camera::Camera(320, 240);
int cam_w = -1;
int cam_h = -1;
image::Format cam_fmt = image::Format::FMT_RGB888;
int cam_fps = -1;
int cam_buffer_num = 3;
if (argc > 1) {
if (!strcmp(argv[1], "-h")) {
log::info("./camera_display <width> <height> <format> <fps> <buff_num>");
log::info("example: ./camera_display 640 480 0 60 2");
exit(0);
} else {
cam_w = atoi(argv[1]);
}
}
if (argc > 2) cam_h = atoi(argv[2]);
if (argc > 3) cam_fmt = (image::Format)atoi(argv[3]);
if (argc > 4) cam_fps = atoi(argv[4]);
if (argc > 5) cam_buffer_num = atoi(argv[5]);
log::info("Camera width:%d height:%d format:%s fps:%d buffer_num:%d", cam_w, cam_h, image::fmt_names[cam_fmt].c_str(), cam_fps, cam_buffer_num);

camera::Camera cam = camera::Camera(cam_w, cam_h, cam_fmt, "", cam_fps, cam_buffer_num);
display::Display disp = display::Display();
log::info("camera and display open success\n");
log::info("camera size: %dx%d\n", cam.width(), cam.height());
Expand Down

0 comments on commit a661491

Please sign in to comment.