Questions tagged [opencv-solvepnp]

This tag is used in questions related to estimating the pose of an object. In other words, the relative orientation and position with respect to a camera

The 'PNP' in solvepnp means Perspective-n-Point.

For more details camera calibration and 3D reconstruction has a detailed explanation. And if that is not enough, Head pose estimation using OpenCV can help you further.

76 questions
23
votes
1 answer

Can you use OpenCV solvePNP with a equirectangular image?

Is it possible to use OpenCV's solvePNP with an equirectangular image? I have an equirectangular image and I have four points in this image (red dots) and their pixel coordinates, and then I have 4 corresponding world points e.g. [(0, 0, 0), (2, 0,…
nickponline
  • 22,615
  • 27
  • 86
  • 138
19
votes
1 answer

Camera pose from solvePnP

Goal I need to retrieve the position and attitude angles of a camera (using OpenCV / Python). Definitions Attitude angles are defined by: Yaw being the general orientation of the camera when it lays on an horizontal plane: toward north=0, toward…
s.k
  • 2,221
  • 4
  • 21
  • 42
9
votes
1 answer

solvePNP vs recoverPose by rotation composition: why translations are not same?

Part 1: Before update I am trying to estimate relative position using two different methods: solvePNP and recoverPose, and seems like R matrices are looks OK with respect to some error, but translation vectors are totally different. What am I…
9
votes
1 answer

Why Direct Linear Transformation (DLT) cannot give the optimal camera extrinsics?

I'm reading the source code of function solvePnP() in OpenCV, when the flags param uses default value SOLVEPNP_ITERATIVE, it's calling cvFindExtrinsicCameraParams2, in which it FIRST uses the DLT algorithm (if we have a non-planar set of 3D points)…
zhangxaochen
  • 19,967
  • 8
  • 46
  • 68
5
votes
0 answers

OpenCV Python solvePnP's EPnP implementation not producing the same output as official MATLAB EPnP implementation

these days I am working on understanding the solvePnP algorithm used for computer vision. I found the official EPnP algorithm in MATLAB here https://github.com/cvlab-epfl/EPnP. I am comparing the results of the official implementation with the…
rassi
  • 130
  • 8
4
votes
0 answers

How to understand Euler angles from cv2.decomposeProjectionMatrix?

I have been searching the internet for hours on some documentation on how to understand the Euler angles returned by cv2.decomposeProjectionMatrix. My problem seems simple, I have this 2D image of an aircraft. I want to be able to derive from that…
Chris Unice
  • 161
  • 2
  • 7
4
votes
1 answer

OpenCV Error: Assertion failed in undistort.cpp at line 293

Found solution at https://github.com/opencv/opencv/issues/4943 OpenCV Error: Assertion failed (CV_IS_MAT(_src) && CV_IS_MAT(_dst) && (_src->rows == 1 || _src->cols == 1) && (_dst->rows == 1 || _dst->cols == 1) && _src->cols + _src->rows - 1…
My Spy
  • 1,221
  • 17
  • 50
4
votes
1 answer

Find rectangular object quality with perspective

I get image from a camera (calibrated and without lens distortions) and I need to detect a rectangular object. Markers are a good example. For markers I check corner count, min size, board contrast and convexity. I had an idea on how to improve this…
user1214513
  • 235
  • 2
  • 4
  • 10
3
votes
0 answers

What does the error fabs(sc) > DBL_EPSILON mean in function cvFindExtrinsicCameraParams2?

I am using the solvePnPRansac function from OpenCV (4.0.0) in python. Sometimes (but not all the time) when I pass points into the function I get an error: (-215:Assertion failed) fabs(sc) > DBL_EPSILON in function `cvFindExtrinsicCameraParams2'…
crock
  • 51
  • 6
3
votes
0 answers

Mismatch between OpenCV projected points and Unity camera view

We are working on an AR application in which we need to overlay a 3D model of an object on a video stream of the object. A Unity scene contains the 3D model and a camera is filming the 3D object. The camera pose is initially unknown. ▶ What we have…
3
votes
1 answer

rvec/tvec from solvePnP vs. rvec/tvec from calibrateCamera

I've read this answer but I still don't understand the rvec/tvec pair returned by calibrateCamera and the rvec/tvec pair returned by solvePnP. I understand that solvePnP solves for [R|T] which is given here. This is very clear - it's an affine…
Carpetfizz
  • 7,466
  • 18
  • 64
  • 121
3
votes
1 answer

Understanding the solvePnP Algorithm

I'm having trouble understanding the Perspective-n-Point problem. A few questions: What is s for? Why do we need a scale factor for the image point? Is K[R|T] a "change of coordinates matrix" which moves p_w, the homogenous world point, into the…
Carpetfizz
  • 7,466
  • 18
  • 64
  • 121
3
votes
1 answer

OpenCV solvePnPRansac

I'm using OpenCV 3.1 on Windows. A snippet of code: RNG rng; // random number generator cv::Mat rVec = (cv::Mat_(3, 1) << 0.08257, -0.6168, 1.4675); cv::Mat tVec = (cv::Mat_(3, 1) << -0.3806, -0.1605, 0.6087); for (int i = 0; i <…
ancajic
  • 4,504
  • 1
  • 41
  • 62
2
votes
1 answer

Where I can find opencv.js with solvePnP or how to build it?

Hello guys) I need function solvePnP from opencv in opencv.js. But I can't find version with solvepnp included. Could you, please, help me to find opencv.js version with solvePnP or build it? Do you know where I can find solvePnP in other js…
2
votes
1 answer

camera pose estimation with solvePnP() and SOLVEPNP_IPPE_SQUARE method

I'm working with ARKit and trying to get camera position from QR code with known size (0.16m). To detect QR code I'am using Vision framework so i can get each corner point on image. Data preparation: let intrinsics = arFrame.camera.intrinsics let…
Dim Roe
  • 23
  • 3
1
2 3 4 5 6