Calculate Object Distance From Camera Opencv Android

You can use these parameters to correct for lens distortion, measure the size of an object in world units, or determine the location of the camera in the scene. txt) or read online for free. Given the distance of an object and camera parameters (focal length) you can calculate the real world dimensions of an object a bit of geometry. A USB web camera is also needed. The Android phone camera capture real-time data and calculate the position and distance of the object with the data using various image processing techniques and calculate the velocity and. So the main idea is, a drone should be able to identify a specified colour and then follow. I found and ordered ELP's stereo camera to calculate depth maps with OpenCV and see what I could do with them. In this article, we will take a tour around the most widespread use case of machine learning, computer vision. Examples of helpful information include information about the camera and lens such as the sensor size and focal length, and also exactly how the. $\begingroup$ Going to use camera calibration from OpenCV to deal with the camera being at an angle. Join me on this exciting journey to apply advanced computer vision techniques to identify lane lines. Android sample app which provides distance of an object from the camera; using contour based image recognition through OpenCV. Triangle Similarity for Object/Marker to Camera Distance. moments() gives a dictionary of all moment values calculated. Our program will be laid out as follows: Import OpenCV and its dependencies. So it is an important question whether we can find the depth information using these cameras. The model file will be then used to detect an object in the live images taken from a USB web camera. In this tutorial, you will learn how to use the ZED SDK to capture and display color and depth images from your ZED. compute the distance. However, for some of our customers it's not enough to simply identify and track. I'm trying to find the distance to an object with my Android. It's available for Android and Apple, and this is how it works. com/8rtv5z/022rl. Given a pattern image, we can utilize the above information to calculate its pose, or how the object is situated in space, like how it is rotated, how it is displaced etc. Creating a Java OpenCV Mat object. Deep Learning Face Detection, Face Recognition & OCR. Yinyoo V2 イヤホン 高音質 最終版 豊満な低域しながら高音も強く カナル型 高遮音性 イヤホン 中華イヤホン 2pin リケーブル 可能 ジュラルミンフェイスプレート搭載 3. Example Python Script - OpenCV Get Image Size. * Bottom edge 1/16ths, 1/32nds, 1/64ths. X by use of matrix we got during our stereo calibration process? or we need another way to do so? Thank you for sharing your knowledge. and i tried to calculate the angle by using get orientation method. However, this open-source library is focused on real-time image processing and definitely extremely hard to master. This chapter teaches you how toad borders to an image. Tutorial: Making Road Traffic Counting App based on Computer Vision and OpenCV OpenCV image filters. It holds vertexes of the camera model and applies rotation according to theta. this image was done for this Q/A: Specifiyng speed from visual size which can be of help. How to calculate a Homography ? To calculate a homography between two images, you need to know at least 4 point correspondences between the two images. so the simple formula for getting Distance of object from camera is distance(mm) = (focal length (mm) * real. The distance between the cameras and the object can be measured depending upon the distance between the positions of the objects in. Following program is an example. moments() gives a dictionary of all moment values calculated. First, if I have two objects in this room, I would like to get the distance between the two stationary objects. Place an object with a highlighted boundry in front of your phone. X - pointLeftImage. Or, with a given height/width, you can calculate distance from an object. The documentation says that get(CAP_PROP_FPS) or get(CV_CAP_PROP_FPS) gives the frames per second. If you see the Welcome to Android Studio dialog, choose Start a new Android Studio project, available under 'Quick Start' on the right of the dialog. If you don't know either, you can at least get a distance/size ratio:. This function is supposed to return a map of all unique local identifiers of images that are on the iPhone using the IOS Photos Framework. Best regards, moris September 1, 2011 at 7:05 AM. But we still do not know what distance threshold is the best boundary for making a decision between same identity and different identity. OpenCV is the most popular computer-vision library with a comprehensive set of vision functions and a large developer community. With opencv_apps, you can skip writing OpenCV application codes for a lot of its functionalities by simply running a launch file that corresponds to OpenCV's functionality you want. This is rather specialized, but people do ask how to determine or measure the distance or size of an object or subject in a photo image. OpenCV - Adaptive Threshold - In simple thresholding, the threshold value is global, i. At the moment, trying to figure out if this is possible without using a comparison object or not. I calculated the distance between the camera and the red ball using the formula: Distance = FocalLength in mm * (Real object width in mm) / (Virtual object width in px) To get the virtual object width, I drew a contour around my thresholded image (I used minEnclosingCircle). Calculate focal length using image width by assuming field of view If you think about it, the field of view of most webcams should be similar because they expect you to be at a certain distance from the camera ( say a foot and a half ), and they would want the face to be a certain size ( not too large, not too small ). The main aim of project a moving object detection and tracking system with a static camera has been developed to estimate velocity, distance parameters We propose a general moving object detection and tracking based on vision system using image difference algorithm. The camera used in this is Logitech HD camera. One of the goals for this project was to build a platform that is completely self contained, requiring no external signals for any system. TERM_CRITERIA_EPS(). It's free to sign up and bid on jobs. I chose the ELP camera because it looked like a low-effort way to get working stereo camera hardware. Porting both OpenCV and applications to mobile devices requires care, however, to retain a sufficient level of performance. rotation) needed by the ball launcher. You can perform this operation on an image using the Canny() method of the imgproc class, following is the syntax of this method. A major design and implementation goal for OpenCV has always been high performance. Riconoscimento automatico oggetti in OpenCV Una delle funzioni piu' carine di OpenCV e' quella che permette di individuare oggetti in automatico all'interno di una immagine. When motion of a suitably sized object is detected, the standard deviation will rise, allowing us to trigger a motion event. Computer vision is a rapidly growing field devoted to analyzing, modifying, and high-level understanding of images. In this article, we will take a tour around the most widespread use case of machine learning, computer vision. Finding distance from camera to the known size object using openCV. You can even OpenCV to calculate distances between objects or an object an the camera if you know the measurements of an object in view. I try to use two wiimote (IR camera) to find the distance of a point but results are wrong. An easier approach is to take two photos which stay on the same line with the object, with object in the center of the image. I am working with the following formula to calculate distance: distance to object (mm) = focal length (mm) * real height of the object (mm) * image height (pixels) -----. Compile opencv with samples by setting BUILD_EXAMPLES to ON in cmake configuration. 23 수정한 코드가 이미지 파일간 매칭을 위한 코드라 동영상에서 동작시 예외상황을 처리하지 못해서 추가했습니다. net/projects/roboking. I think I know what you are asking for. Counting pixels from the center of the image to the laser point allows you to calculate an angle, which can then be used to calculate the distance to the object — of course, this needs to be. convexHull (cnt). so the simple formula for getting Distance of object from camera is distance(mm) = (focal length (mm) * real. As I'm not a specialist on ComputerVision I ask you where I made a mistake. Well, in between client work I've moved a bit forward. (401 A) DESCRIPTION: * Range:- 0 to 150 mm (150 x 15 x 0. and i tried to calculate the angle by using get orientation method. With a combination of the movement of these points and readings from the phone's inertial sensors, ARCore determines both the position and orientation of the phone as it moves through space. OpenCv and Camera. In a stereo system, two cameras are mounted facing in the same direction. To calculate the size of the ball, you must know the distance to the ball. (To see the tutorial) We followed the instructions step by step. Important: This article is outdated (ZED SDK 1. com/translate?u=http://derjulian. Object detection by contours. Distance Calculation Model. Find the view angle (VA1 and VA2) of both cameras. Using the angle provided OpenCV draws a line drawn from each camera to the object being tracked, thus. Search for jobs related to Opencv measure object length or hire on the world's largest freelancing marketplace with 14m+ jobs. The only tracking hardware needed is a camera, which could be the built-in webcamera of the laptops. Notice: Undefined index: HTTP_REFERER in /home/yq2sw6g6/loja. So only the X coordinate is interesting, right? I am using OpenCV and Python for the processing. Calculate focal length using image width by assuming field of view If you think about it, the field of view of most webcams should be similar because they expect you to be at a certain distance from the camera ( say a foot and a half ), and they would want the face to be a certain size ( not too large, not too small ). You can use these parameters to correct for lens distortion, measure the size of an object in world units, or determine the location of the camera in the scene. , it is same for all the pixels in the image. Finding distance from camera to the known size object using openCV. Run the example from Adrian Rosebrock’s blog post. It holds vertexes of the camera model and applies rotation according to theta. eg if the camera width is 320 px then a very close object might cover 320px in a few feet but if it was far away then it might be hundreds of feet to travel the full 320px view of the camera. Object Detection Techniques - OpenCV & Robotics - Free download as PDF File (. convexHull function to obtain processed contour information for convex shapes, and this is a straightforward one-line expression: hull = cv2. 5mm プラグ (グレー),AQUOS R2 sense アクオス SH-03K SHV42 SH-01K SHV40 ケース スワロフスキー カバー デコ 送料無料 デコケース デコカバー. If you don't know either, you can at least get a distance/size ratio:. These quantities are related by the so-called thin lens equation: In computer vision, this camera model can be simplified in a number of ways. How to Measure Distance on Android. Real-time Distance Measurement between a camera and an object using a single image. Effectively, we’re instructing OpenCV to calculate an approximated polygon whose perimeter can only differ from the original contour in an epsilon ratio. Following is the syntax of this. Program receives an X,Y array of pixels for each image frame from camera. You should know that the parameters depend on the camera and will change if the camera is changed. This article is for a person who has some knowledge on Android and OpenCV. Notice: Undefined index: HTTP_REFERER in /home/yq2sw6g6/loja. To accomplish this task we utilized the triangle similarity, which requires us to know two important parameters prior to applying our algorithm: The width (or. We propose vision measurement scheme for estimating the distance or size of the object in static scene, which requires single camera with 3-axis accelerometer sensor rotating around a fixed axis. See more: measure object length using picture, detect moving object video matlab, detect moving object matlab, measure objects in photo, how to calculate distance from camera to object in android, measuring size of objects in an image with opencv, image processing determine size of object, opencv object measurement, measure object size from. The obtained equations are shown below, we have calculated the parameters using different known positions of an object: Program to publish the position of the objects. Take image of an object and save in any one pc, 3rd. EasyMeasure shows you the distance to objects seen through the camera lens of your Android device. We have got what we were trying. Before you begin, follow this tutorial to cross-compile the OpenCV library for Raspberry Pi or this one to use a pre-built one and this tutorial to setup the raspicam library that allows obtaining images from the Raspberry Pi camera. 2/ I record 20 points (each 300ms) to calculate the fundamental matrix (I moved back). Since the position of the marker is estimated from the 2D image, it is not always possible to estimate the exact depth. VideoCapture(0) to access the camera and set the capture object (cap). They are extracted from open source Python projects. With a pi camera I record a video and in real time I can recognize blue from other colors (I see blue as white and other colors as black). We believe this is due to the fact that the camera app already knows the camera matrix and applies some pre-processing to the raw image collected. You can do rowsum (or colsum) to get close to region of max pixel. x version (although most of the tutorials will work with OpenCV 2. Then we need to calculate the range to the object based on where along the y axis of the image this laser dot falls. d0 - distance from camera image was taken [m] take the image. The proposed. We have used the variation of area of the boundary box in order to calculate the distance between the recognized object and the webcam lens. Best regards, moris September 1, 2011 at 7:05 AM. This post is about face detection on Android and iOS only since they have built-in support this. Finding distance from camera to the known size object using openCV. I am trying to calculate the homography matrix leaving the camera fixed and using the chessboard. The next steps for this project is to also install a camera for object recognition in other to improve it's smooth navigation and help achieve environmental awareness etc. Choose initial search window size and. It's free to sign up and bid on jobs. solvePnP->Distance. In order to determine the distance from our camera to a known object or marker, we are going to utilize triangle similarity. As input it is required to use a camera or a video recorder. The pinhole (monocular) camera generates a one-to-one relationship between the object and the image. Introduction. Or, with a given height/width, you can calculate distance from an object. Apply thresholding. Since Android provides an API to query the field-of-view (FOV) of the device camera, we can determine the focal length of the camera from its FOV. You will need a known value to take measurements with the camera and motion sensor. OpenCV has been available on Android since the Google Summer of Code 2010 when it was first built and run on Google Nexus One. imgproc package. Given a pattern image, we can utilize the above information to calculate its pose, or how the object is situated in space, like how it is rotated, how it is displaced etc. My idea was to use the focal length of the lens in combination with the X-Offset of the detected object from the sensor middle, but i do get weird angles from that. This project is the C++ implementation of kernel based object tracking as discussed by Visvanathan Ramesh, Dorin Comaniciu & Peter Meer in their paper "Kernel-Based Object Tracking". A customized camera calibration…. ファッション > 【送料無料】天然木タモ無垢材ダイニング〔unica〕ユニカ/ベンチタイプ4点セット(A)(テーブルW115. Find the internal angle of both camera (IA1 and IA2). findHomography(). Just point the camera in the direction of a nearby object, and the application will calculate the distance between the camera and the object. Hi everyone i am new to OpenCV and I have to design a code to find out the distance between the detected object and the camera using opencv with c++. It accepts a gray scale image as input and it uses a multistage algorithm. Object detection and distance calculation based on stereo vision technique you can chose father distance for the best result with your camera's type + Before running "Detect objects & compute. Real-time Distance Measurement between a camera and an object using a single image. shape: Height is at index 0, Width is at index 1; and number of channels at index 2. Is it possible to calculate the distance of an object to the camera with two pictures which are taken a few cm apart? It depends. We will use the ObjectReco sample app as a reference (code snippets below). ヤマダコーポレーション オプション ドラムポンプ用耐油ホース2m op-2mh,カクダイ【#vr-4434b0030012】角型洗面器,[ターニングチップ]三菱マテリアル(株) 三菱 旋盤用 CVDコーテッドインサートネガ 鋳鉄加工用 dnmg150408-mk 10個【667-9013】. HTML5 Audio Spectrum Visualizer. Or, with a given height/width, you can calculate distance from an object. How to build a distance sensor with Arduino You can safely say that when it comes to electronics, there are countless ways to measure distances. Adaptive thresholding is the method where the threshold. The pinhole (monocular) camera generates a one-to-one relationship between the object and the image. Object Detection Tutorial (YOLO) Description In this tutorial we will go step by step on how to run state of the art object detection CNN (YOLO) using open source projects and TensorFlow, YOLO is a R-CNN network for detecting objects and proposing bounding boxes on them. Introduction. com Calculating distance/depth using single camera. Now I'm calculating the angle of a line between two tracked points…. However, with the introduction of the cheap pinhole cameras in the late 20th century, they became a common occurrence in our everyday life. Now we can take an image and undistort it. see this : Finding distance from camera to object of known size. After that, we’ll be developing an android application to get the distance of a node object from the camera. In android tutorial we mentioned in our older posts there is another example application named viewfinder. The ratio of the size of the object (imageHeight) in picture and the height of the object in real life is the same as the ratio between the focal length and distance of object and camera. Calculate distance between frames. I calculated the distance between the camera and the red ball using the formula: Distance = FocalLength in mm * (Real object width in mm) / (Virtual object width in px) To get the virtual object width, I drew a contour around my thresholded image (I used minEnclosingCircle). That is, the camera is the origin and the chessboard has been displaced. Search for jobs related to Opencv measure object length or hire on the world's largest freelancing marketplace with 14m+ jobs. I have had this idea for some long time now (6yrs+) but havent really had a chance to develop it further. OpenCV is the most popular computer-vision library with a comprehensive set of vision functions and a large developer community. It's free to sign up and bid on jobs. But we still do not know what distance threshold is the best boundary for making a decision between same identity and different identity. You can continue measure the height of object by lock the distance and. How can I measure distance from two cameras? I want to get real depth/distance from camera to object. In general, it is not possible. In order to determine the distance from our camera to a known object or marker, we are going to utilize triangle similarity. The operations we are going to perform are. Triangle Similarity for Object/Marker to Camera Distance. Use Hessian Matrix and Scale Space to calculate key points of an image 2. I am working with the following formula to calculate distance: distance to object (mm) = focal length (mm) * real height of the object (mm) * image height (pixels) -----. Now we can take an image and undistort it. This article is for a person who has some knowledge on Android and OpenCV. moments() gives a dictionary of all moment values calculated. if you are using DSLR, then there is a distance scale in the lens. This guide is mainly focused on OpenCV 3. 1/ I use two cameras uncalibrate (2 wiimotes) and place them to cover a dedicate place. OpenCV의 SURF 예제를 테스트 해보았습니다. AlignMTB CALIB_CB_ADAPTIVE_THRESH - Static variable in class org. It shows you the distance to objects seen through the camera lens of your android device. OpenCV and Python (Documentation) Sai Prashaanth. The histogram may have strong maximums, corresponding to the dominant colors in the object. 4+ and OpenCV 2. So now you can see how simple combination of deep learning and OpenCV can produce interesting results. These quantities are related by the so-called thin lens equation: In computer vision, this camera model can be simplified in a number of ways. Choose a name for your package, for the FXML file and for the Controller Class. You can perform this operation on an image using the Canny() method of the imgproc class, following is the syntax of this method. What we'll attempt to achieve in this tutorial is tracking the location of a coloured object in an image. The Android phone camera capture real-time data and calculate the position and distance of the object with the data using various image processing techniques and calculate the velocity and. In this tutorial we will learn that how to do image segmentation using OpenCV. Please can anyone help me out. Situation like this: I know the green intersections, therefore the width in between and both sides (not the length obvious). Thakare, Kote Shubham, Pawale Ankit, Rajguru Ajinkya, Shelke Om Abstract- Physical movement is one of the biggest challenges for the visually impaired. To calculate the projection matrix without taking Gate fit into account, use Camera. Also i computed the distance of the object to the camera and everything is on one level. I have had this idea for some long time now (6yrs+) but havent really had a chance to develop it further. shape to get the dimension. com Need to measure someth…. Place an object with a highlighted boundry in front of your phone. The operations we are going to perform are. The class holds theta itself, which is updated on each IMU frame. Kari Pulli, NVIDIA Research Anatoly Baksheev, Itseez Kirill Kornyakov, Itseez Victor Eruhimov, Itseez. In the sample video, you could decide that the average number of cars on the road is good enough to describe that video, but as discussed earlier you can apply this to many more use cases if you have the ability to track objects in motion, count them as they enter your area of interest, and calculate a rate or a latency. The method getFocusDistances(float[] output) of android. Android sample app which provides distance of an object from the camera; using contour based image recognition through OpenCV. Techniques like Faster R-CNN produce jaw-dropping results over multiple object classes. There are many algorithms used to do the same thing too. In the sample video, you could decide that the average number of cars on the road is good enough to describe that video, but as discussed earlier you can apply this to many more use cases if you have the ability to track objects in motion, count them as they enter your area of interest, and calculate a rate or a latency. Please see the new OpenCV guide here. If you want to determine exactly how fast a particular object, like a car or person is travelling, you can do so with a free Android app. Kari Pulli, NVIDIA Research Anatoly Baksheev, Itseez Kirill Kornyakov, Itseez Victor Eruhimov, Itseez. I try to use two wiimote (IR camera) to find the distance of a point but results are wrong. Compile opencv with samples by setting BUILD_EXAMPLES to ON in cmake configuration. This distance between pixels is obviously true for a certain distance from the camera (i. AlarmClock; BlockedNumberContract; BlockedNumberContract. So the main idea is, a drone should be able to identify a specified colour and then follow. Any input welcomed. Camera calibration With OpenCV¶ Cameras have been around for a long-long time. Important: This article is outdated (ZED SDK 1. For webcams and many other connected cameras, you have to calculate the frames per second manually. Not too long ago I mentioned I was playing around with opencv and python. The best way to make it, it's to use android phone with special app which check view from camera recognize position of red color and sends it to arduino over bluetooth. In order to determine the distance from our camera to a known object or marker, we are going to utilize triangle similarity. so the simple formula for getting Distance of object from camera is distance(mm) = (focal length (mm) * real. Using this principle, we can deduce a relationship between known parameters: focal length (f), radius of marker in the image plane (r), and radios of marker in the object plane (R) and unknown parameter, distance from the camera to the object(d). Camera calibration is a necessary step in 3D computer vision in order to extract metric information from 2D images. Given a pattern image, we can utilize the above information to calculate its pose, or how the object is situated in space, like how it is rotated, how it is displaced etc. Any input welcomed. Distance and resolution variations need to be done to determine the best distance and minimum resolution required by the system to properly acquire the beef image. OpenCV and Python (Documentation) Sai Prashaanth. First, if I have two objects in this room, I would like to get the distance between the two stationary objects. So, we DO NOT recommend them to be used by professional means. But this approach gives you oversegmented result due to noise or any other irregularities in the image. Calculate the distance between two objects Learn more about im2bw, find, doit4me Image Processing Toolbox. 5 mm) * FRONT SIDE: Top edge 1/2 mm, mm. For a planar object, we can assume Z=0, such that, the problem now becomes how camera is placed in space to see our pattern image. Distance threshold. Most of the time, you can use a list for arguments instead of using a Vector. This project is used to compute the distance from a known object in an image to our camera. Can any one help me with the code?? Thanks in advance!. If you're just looking for the code, you can find the full code here:. Given a pattern image, we can utilize the above information to calculate its pose, or how the object is situated in space, like how it is rotated, how it is displaced etc. Detection of moving objects and motion-based tracking are important components of many computer vision applications, including activity recognition, traffic monitoring, and automotive safety. If you see the Welcome to Android Studio dialog, choose Start a new Android Studio project, available under 'Quick Start' on the right of the dialog. Then we need to calculate the range to the object based on where along the y axis of the image this laser dot falls. It's free to sign up and bid on jobs. In this variables I only know the real height of the object (mm) and image height (pixels) and object height (pixels) but I dont know. I am using code from "Learning OpenCV" (Gary Bradski, Adrian Kaehler) page 446. TERM_CRITERIA_EPS(). The copyMakeBorder() Method. Techniques like Faster R-CNN produce jaw-dropping results over multiple object classes. HEnce the constant pf proportionality is calculated and stored in text. let me give you an example that hopefully explains the difficulty ;-) : i am standing on a boat and see another boat passing. You will need a known value to take measurements with the camera and motion sensor. Riconoscimento automatico oggetti in OpenCV Una delle funzioni piu' carine di OpenCV e' quella che permette di individuare oggetti in automatico all'interno di una immagine. android opencv distance-calculation validation and distance calculation (distance-matrix. The core idea of SURF algorithm can be summarized to the followings: 1. Step 1 - Take Image as Input from a Camera. opencv complete dummies guide to computer vision with python udemy course free download. Riconoscimento automatico oggetti in OpenCV Una delle funzioni piu' carine di OpenCV e' quella che permette di individuare oggetti in automatico all'interno di una immagine. Canny Edge Detection is used to detect the edges in an image. I am using Android…. I know the real size of object, also done some camera calibration with OpenCV to calculate focal length, camera matrix and distortion parameters as well. Download with Google Download with Facebook or download with email. An easier approach is to take two photos which stay on the same line with the object, with object in the center of the image. Deep Learning Face Detection, Face Recognition & OCR. $\begingroup$ Going to use camera calibration from OpenCV to deal with the camera being at an angle. So the main idea is, a drone should be able to identify a specified colour and then follow. In practice, most Android devices possess the ability to respond to multiple consecutive touches (though it is important to note that the number of simultaneous touches that can be detected varies depending on the device). The solution. rotation) needed by the ball launcher. 5mm プラグ (グレー),AQUOS R2 sense アクオス SH-03K SHV42 SH-01K SHV40 ケース スワロフスキー カバー デコ 送料無料 デコケース デコカバー. Optimized usage¶. Distance Calculation Model. For example, if you want to calculate the distance between 2 points:. there is no such function available in opencv to calculate the distance between object and the camera. However, with the introduction of the cheap pinhole cameras in the late 20th century, they became a common occurrence in our everyday life. I know the real size of object, also done some camera calibration with OpenCV to calculate focal length, camera matrix and distortion parameters as well. This tutorial shows how to use the OpenCV library to process the images obtained from the OpenCV camera. Here is what you can do. Take image of an object and save in any one pc, 3rd. To meet the requirements sometimes you can spend many hours just to sort and identify the sensors that would be the best for an application like detecting and tracking an object. Or, with a given height/width, you can calculate distance from an object. There’s an app for that, several, actually. the value of the center pixel) If the camera matrix is K. Finally we use the reference coordinates and the object coordinates to compute and display distance vectors from each of the reference objects corners to the respective corner on the object we found, using the reference distance to calculate the accurate scaled distance. If we pass the set of points from both the images, it will find the perpective transformation of that object. Given the distance of an object and camera parameters (focal length) you can calculate the real world dimensions of an object a bit of geometry. Mount your object in front of the camera so it is on the left of the image and the same distance from the camera as your plant. It accepts a gray scale image as input and it uses a multistage algorithm. Calculate the distance between two objects Learn more about im2bw, find, doit4me Image Processing Toolbox. Any input welcomed. Place an object with a highlighted boundry in front of your phone. What we do is to give different labels for our object we know. Say a object which (in your case : ball) is say 5 cm in real world is represented using 30 pixels, then the distance between object which is 300 pixels on image can be calculate as (300 * 5 / 30). Parameters gets the distances from the camera to where an object appears to be in focus. Canny Edge Detection is used to detect the edges in an image. findHomography(). Our program will be laid out as follows: Import OpenCV and its dependencies. One of the goals for this project was to build a platform that is completely self contained, requiring no external signals for any system. Calculate focal length using image width by assuming field of view If you think about it, the field of view of most webcams should be similar because they expect you to be at a certain distance from the camera ( say a foot and a half ), and they would want the face to be a certain size ( not too large, not too small ). Calculate distance between frames. How to set camera FPS in OpenCV? CV_CAP_PROP_FPS is a fake. You can use these parameters to correct for lens distortion, measure the size of an object in world units, or determine the location of the camera in the scene. So only the X coordinate is interesting, right? I am using OpenCV and Python for the processing.