- 设备型号:MIIVII Apex AD10
- 镜像版本:5.1.2-3.0.0.45
复制代码
- 需将多路GMSL2摄像头同步数据保存,同时需要保存cameras_sdk_demo中
- mvcam.GetImagePtr(outbuf, timestamp, camera_no, g_camera_dev)
复制代码 函数返回的timestamp,存在0值的情况。 - 我终止保存时间戳的程序,过了一段时间,重新再次打开时timestamp保存正常。
- /*demo程序主函数,分别打开n个窗口,并通过反复分别调用GetImageCvMat和GetImagePtr接口获取图像和时间戳在窗口中显示*/
- int main(int argc, char *argv[]) {
- camera_context_t ctx[8] = {};
- stCameraCfgSend.async_camera_num = 0;
- stCameraCfgSend.async_freq = 0;
- stCameraCfgSend.async_camera_bit_draw = 0;
- stCameraCfgSend.sync_camera_num = 8;
- stCameraCfgSend.sync_freq = 30;
- stCameraCfgSend.sync_camera_bit_draw = 0xff;
- if (!parse_cmdline(argc, argv)) {
- return -1;
- }
- char dev_node_tmp = dev_node[10];
- for(int i = 0; i < camera_num; i++){
- dev_node[10] = dev_node_tmp + i;
- ctx[i].dev_node = dev_node;
- ctx[i].camera_fmt_str = camera_fmt_str;
- ctx[i].output_fmt_str = output_fmt_str;
- ctx[i].cam_w = cam_w;
- ctx[i].cam_h = cam_h;
- ctx[i].out_w = out_w;
- ctx[i].out_h = out_h;
- }
- miivii::MvGmslCamera mvcam(ctx, camera_num, stCameraCfgSend);
- std::string windowName("DisplayCamera ");
- for (uint32_t i = 0; i < camera_num; i++) {
- cv::namedWindow(windowName + std::to_string(i), cv::WindowFlags::WINDOW_AUTOSIZE);
- cv::moveWindow(windowName + std::to_string(i), 200 * i, 200 * i);
- }
- cv::Mat outMat[camera_num];
- uint8_t *outbuf[camera_num];
- cv::Mat imgbuf[camera_num];
- signal(SIGINT, &handler);
- bool quit = false;
- uint64_t timestamp;
-
- // save videos for every camera
- // 初始化自定义保存视频数据和timestamp变量
-
-
- while (!quit) {
- if (exitRequested) {
- quit = true;
- break;
- }
- uint8_t camera_no = dev_node[10] - 0x30;
- /*use cv data to get image*/
- // 这里删除mvcam.GetImageCvMat(outMat, timestamp, camera_no, g_camera_dev)
- /*use raw data to get image*/
- if (mvcam.GetImagePtr(outbuf, timestamp, camera_no, g_camera_dev)) {
- for (uint32_t i = 0; i < camera_num; i++) {
- if ( ctx[i].output_fmt_str == "UYVY") {
- imgbuf[i] = cv::Mat(out_h, out_w, CV_8UC2, outbuf[i]);
- cv::Mat mrgba(out_h, out_w, CV_8UC3);
- cv::cvtColor(imgbuf[i], mrgba, cv::COLOR_YUV2BGR_UYVY);
- cv::imshow(windowName + std::to_string(i), mrgba);
- } else if (ctx[i].output_fmt_str == "ABGR32") {
- imgbuf[i] = cv::Mat(out_h, out_w , CV_8UC4, outbuf[i]);
- cv::cvtColor(imgbuf[i], imgbuf[i], cv::COLOR_RGBA2BGR);
- cv::imshow(windowName + std::to_string(i), imgbuf[i]);
- } else if (ctx[i].output_fmt_str == "BGRA32") {
- imgbuf[i] = cv::Mat(out_h, out_w , CV_8UC4, outbuf[i]);
- cv::cvtColor(imgbuf[i], imgbuf[i], cv::COLOR_BGRA2BGR);
- cv::imshow(windowName + std::to_string(i), imgbuf[i]);
- // write frame to video
- // 保存时间戳,这里是问题所在处,使用mvcam.GetImagePtr(outbuf, timestamp, camera_no, g_camera_dev)
- // 保存同步函数所返回的timestamp,存在0值得情况。
- timestamp_in[i]<<timestamp<<"\n";
- }
- CheckTimeStampLog(timestamp,dev_node_tmp - 0x30 + i);
- }
-
- // 一些处理
- } else {
- std::cerr << "Can't get image form camera." << std::endl;
- }
- //auto t2 = std::chrono::steady_clock::now();
- //double dr_ms = std::chrono::duration<double, std::milli>(t2 - t1).count();
- //printf("GetImagePtr dr_ms: %f\n", dr_ms);
- if (cv::waitKey(1) == 27) {// Wait for 'esc' key press to exit
- break;
- }
- }
- // free resources
- // 释放资源
- return 0;
- }
复制代码
- 问题,我在保存米文cameras_sdk_demo中得到的同步时间戳,为什么会存在0值得情况?同时,过一段时间再次打开,保存时间戳正常。
|
-
demo中函数保存timestamp存在0值的情况
-
AD10采用授时方式
-
demo中函数保存timestamp正常的情况
|
|
|
|
共 1 个关于本帖的回复 最后回复于 2024-3-18 17:59