快捷导航
HI:
     各位水友,我调用opencv 的undistort函数,视频没有得到矫正,请教一下原因。
  1. else if (imgFmt == "ABGR32")
  2.                 {
  3.                     imgbuf[i] = cv::Mat(imgHeight, imgWidth, CV_8UC4, outbuf[i]);
  4.                     cv::cvtColor(imgbuf[i], imgbuf[i], cv::COLOR_RGBA2BGR);
  5.                     cv::imshow(windowName + std::to_string(i), imgbuf[i]);
  6.                     cv::Mat cb_final;
  7.                     std::cout << "camera Matrix is " << cameraMatrix << std::endl;
  8.                     std::cout << "distCoeffs is " << distCoeffs << std::endl;

  9.                     undistort(imgbuf[i], cb_final, cameraMatrix, distCoeffs);
  10.                     cv::imshow("ccccccc", cb_final);
  11.                 }
复制代码
终端打印的标定参数
camera Matrix is [414.3595, 0.81274998, 640.57178;
0, 362.49072, 364.70981;
0, 0, 1]
distCoeffs is [-0.045435999, 0.015187, -0.0028009999, -0.00065599999, 0]

标定也加载上了,就是图像没有被矫正。
举报 使用道具
| 回复

共 6 个关于本帖的回复 最后回复于 2021-4-15 18:46

Hcheng 游客 发表于 2021-4-15 17:09 | 显示全部楼层
看您的代码,好像问题不大。
所以结果很可能还是标定的参数。

建议您参考opencv的示例
https://docs.opencv.org/3.4/d4/d ... ra_calibration.html
1. 先把示例跑通,确认基础代码没有问题。
2. 把相机图片存下来,用示例代码运行,以确保标定数据没有问题。
3. 把示例代码中再迁移到您的程序里面。

目前目测您在第二步的过程中,能够发现问题在哪里。
但是光靠这段代码还是比较难判断的。
起码camera Matrix已经和opencv要求的不太一样了。
https://docs.opencv.org/2.4.13.7 ... ml#void%20undistort(InputArray%20src,%20OutputArray%20dst,%20InputArray%20cameraMatrix,%20InputArray%20distCoeffs,%20InputArray%20newCameraMatrix)
孤云独去闲 游客 发表于 2021-4-15 17:33 | 显示全部楼层
标定参数是用ros  camera_calibration模块标定出来的。  如果参数不对,那应该是矫正的不好,甚至更扭曲。但是现在的输出结果看,一点变化都没有。两组视频一模一样。
Hcheng 游客 发表于 2021-4-15 17:35 | 显示全部楼层
孤云独去闲 发表于 2021-4-15 17:33
标定参数是用ros  camera_calibration模块标定出来的。  如果参数不对,那应该是矫正的不好,甚至更扭曲 ...

这个不一定的。
不排除如果不符合其参数定义,就不进行处理。
所以还是建议把图片存下来,用官方demo先排查一下。
孤云独去闲 游客 发表于 2021-4-15 17:36 | 显示全部楼层
调用 cv::fisheye::undistortImage(imgbuf[i], cb_final, cameraMatrix, distCoeffs);编译能过,运行报错。
Failed to load module "canberra-gtk-module"
camera Matrix is [414.3595, 0.81274998, 640.57178;
0, 362.49072, 364.70981;
0, 0, 1]
distCoeffs is [-0.045435999, 0.015187, -0.0028009999, -0.00065599999, 0]
terminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(4.1.1) /home/nvidia/host/build_opencv/nv_opencv/modules/calib3d/src/fisheye.cpp:437: error: (-215:Assertion failed) K.size() == Size(3, 3) && (D.empty() || D.total() == 4) in function 'initUndistortRectifyMap'

Aborted (core dumped)
这又是什么原因?
Hcheng 游客 发表于 2021-4-15 17:49 | 显示全部楼层
孤云独去闲 发表于 2021-4-15 17:36
调用 cv::fisheye::undistortImage(imgbuf, cb_final, cameraMatrix, distCoeffs);编译能过,运行报错。
Fa ...

您可以看下这个问题:
https://github.com/JetsonHacksNano/CSI-Camera/issues/6
孤云独去闲 游客 发表于 2021-4-15 18:46 | 显示全部楼层
OK,问题找到了。畸变有5个参数,最后一个参数是0,但是OPENCV对畸变变量的定义,是4个参数。
现在问题就是内参不正确,矫正之后畸变还是很大。我重新标定再试试。
您需要登录后才可以回帖 登录 | 点我注册

精彩推荐

  • canbus与vcu相连接,出现bus-off状态
  • 有线连接失败
  • Apex 串口通讯
  • 关于SPI通信问题咨询
  • MIIVII APEX DUAL ORIN米文域控制器产品合

明星用户