
LENS STUDIO 3D OBJECTS DRIVER
Now that we understand the “pixels per metric” ratio, we can implement the Python driver script used to measure the size of objects in an image. Measuring the size of objects with computer vision Using this ratio, we can compute the size of objects in an image. Thus implying there are approximately 157 pixels per every 0.955 inches in our image. Now, suppose that our object_width (measured in pixels) is computed be 150 pixels wide (based on its associated bounding box). Pixels_per_metric = object_width / know_widthĪ US quarter has a known_width of 0.955 inches. In this example, we’ll be using the United States quarter as our reference object and throughout all examples, ensure it is always the left-most object in our image:įigure 1: We’ll use a United States quarter as our reference object and ensure it is always placed as the left-most object in the image, making it easy for us to extract it by sorting contours based on their location.īy guaranteeing the quarter is the left-most object, we can sort our object contours from left-to-right, grab the quarter (which will always be the first contour in the sorted list), and use it to define our pixels_per_metric, which we define as: In either case, our reference should should be uniquely identifiable in some manner. Property #2: We should be able to easily find this reference object in an image, either based on the placement of the object (such as the reference object always being placed in the top-left corner of an image) or via appearances (like being a distinctive color or shape, unique and different from all other objects in the image).Property #1: We should know the dimensions of this object (in terms of width or height) in a measurable unit (such as millimeters, inches, etc.).Our reference object should have two important properties: In order to determine the size of an object in an image, we first need to perform a “calibration” (not to be confused with intrinsic/extrinsic calibration) using a reference object.

I call this the “pixels per metric” ratio, which I have more formally defined in the following section. Measuring the size of objects in an image is similar to computing the distance from our camera to an object - in both cases, we need to define a ratio that measures the number of pixels per a given metric.
LENS STUDIO 3D OBJECTS CODE
Looking for the source code to this post? Jump Right To The Downloads Section Measuring the size of objects in an image with OpenCV
