I have a fixed camera so I know the distance between the camera to the ground, as well as the distance between the camera and the bottom line in the image (which is the floor).
I have an object in the image and I need to calculate the distance to it. However, the actual dimensions of the object are not available.
In the first image, the distance to the object is 75cm. In the second image the distance is 33cm.
How can I calculate the distances using the fixed camera? I found a few tutorials which used the focal length and the width of the object, however I cannot use it.
I can detect the object and have a bounding box around it.
Thanks
Related
I have done some 6D Pose estimation, and have the Oriented Bounding Box (OBB) of the detected object. So, now I would like to know the ground truth and get the error of the estimated orientation and the position. The detected object is a rectangular box as shown in the image.
How can I know the distance and the rotation of a marker (black box over the red one) to the camera? The red box in the image is the object and the black one is the estimated 6DPose.
So would like to do image postprocessing to get the error of the position and the orientation. So, how can get the error from this image, knowing the real dimensions of the box, camera parameters, and the distance from the camera to the object? So the triangulation formula can give me the distance but then how to get the orientation?
Would be OpenCV to look after?
Any help?
Thanks
find the marker correspondings and solvePnp is what you are looking for
How can I calculate the distance of an object of known size (e.g. aruco marker of 0.14m printed on paper) from camera. I know the camera matrix (camMatx) and my fx,fy ~= 600px assuming no distortion. From this data I am able to calculate the pose of the aruco marker and have obtained [R|t]. Now the task is to get the distance of the aruco marker from the camera. I also know the height of the camera from ground plane (15m).
How should I go about solving this problem. Any help would be appreciated. Also please note I have also seen approach of similar triangles, but that would work on knowing the distance of the object, which doesnt apply in my case as I have to calculate the distance.
N.B: I dont know the camera sensor height. But I know how high the camera is located above ground.
I know the dimensions of the area in which my object is moving (70m x 45m). In the end I would like to plot the coordinate of the moving object on a 2D map drawn to the scale.
In the book Learning OpenCV, there is one figure that show the image plane always is focal image.
The description of the figure from the book is as follow.
We begin by looking at the simplest model of a camera, the pinhole camera model. In this simple model, light is envisioned as entering from the scene or a distant object, but only a single ray enters from any particular point. In a physical pinhole camera, this point is then “projected” onto an imaging surface. As a result, the image on this image plane(also called the projective plane) is always in focus, and the size of the image relative to the distant object is given by a single parameter of the camera: its focal length. For our idealized pinhole camera, the distance from the pinhole aperture to the screen is precisely the focal length. Th is is shown in Figure 11-1, where fis the focal length of the camera, Zis the distance from the camera to the object, Xis the length of the object, and xis the object’s image on the imaging plane. In the figure, we can see by similar triangles that –x/f = X/Z,
From this link https://en.wikipedia.org/wiki/Lens_(optics)
There is thin lens equation. Only object in infinity can be imaged in focal image. Which one is correct?
Both are correct but they're stating different subjects. The mentioned Wikipedia's page is not talking about pinhole camera model. In pinhole camera you can put the image plane in any distance that you want (limited to the size of the image plane) and the image would be formed on that anyway. However in the second model that you brought from Wikipedia, the image plane has to be somewhere that is matched with the formula because of the existence of the lens, and that's the reason you have blur image when you take a picture out of the camera's focus.
In other word with a specific lens, there is a predefined focal length, so you have to set your image plane in a distance that gives you the clear image (Of course in digital camera, this distance is constant but there are multiple lenses and the camera changes the focal length by moving the lenses). In pinhole model there is no lens so there is no predefined focal length and the image will be caught correctly wherever you put the catcher plane. (There are many things that we have to consider but I came up with the simplest sketch.)
I have a phone camera that’s viewing a planar object. I know the real world measurements of the object. Considering the top left corner of the object as the origin, I calculate the coordinates using the real world measurements. With the object detection algorithm I am able to get the coordinates of the detected object on the image, which is in pixels. (again going by the fact that the image's origin is on the top left hand corner). I obtain the Rotation and Translation matrix using solvepnp(). Now is it possible (with the obtained parameters) to find the distance and the height of the object with respect to the first frame?
I am trying to write a program using opencv to calculate the distance from a webcam to a one inch white sphere. I feel like this should be pretty easy, but for whatever reason I'm drawing a blank. Thanks for the help ahead of time.
You can use triangle similarity to calibrate the camera angle and find the distance.
You know your ball's size: D units (e.g. cm). Place it at a known distance Z, say 1 meter = 100cm, in front of the camera and measure its apparent width in pixels. Call this width d.
The focal length of the camera f (which is slightly different from camera to camera) is then f=d*Z/D.
When you see this ball again with this camera, and its apparent width is d' pixels, then by triangle similarity, you know that f/d'=Z'/D and thus: Z'=D*f/d' where Z' is the ball's current distance from the camera.
To my mind you will need a camera model = a calibration model if you want to measure distance or other things (int the real-world).
The pinhole camera model is simple, linear and gives good results (but won't correct distortions, (whether they are radial or tangential).
If you don't use that, then you'll be able to compute disparity-depth map, (for instance if you use stereo vision) but it is relative and doesn't give you an absolute measurement, only what is behind and what is in front of another object....
Therefore, i think the answer is : you will need to calibrate it somehow, maybe you could ask the user to approach the sphere to the camera till all the image plane is perfectly filled with the ball, and with a prior known of the ball measurement, you'll be able to then compute the distance....
Julien,