# Extracting range of an object from an image using object's dimesntions

1 Ansicht (letzte 30 Tage)
Alla am 18 Aug. 2017
Kommentiert: Image Analyst am 21 Aug. 2017
So I have a code that detects and isolates three objects and yields their dimensions in pixels (diamters, perimeter..), I have the ground truth data for the distance but I would like to be able to estiamte the distance from the inforamation I have efficiently, suggestions to how this could be done would be great. The picture shows a frame from over a thousand frames I have that show the object slowly drifting closer, so obviously the closer it is the larger its measurements are.
##### 0 Kommentare-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

Image Analyst am 18 Aug. 2017
Measure the diameters and separation for images taken at multiple distances. Then divide the actual diameters and separation by the pixel ones to get a spatial calibration. Then plot spatial calibration vs. distance to get a curve. Fit to a polynomial with polyfit to get a formula where you can convert the real world diameters into a distance from the camera.
##### 2 Kommentare1 älteren Kommentar anzeigen1 älteren Kommentar ausblenden
Image Analyst am 21 Aug. 2017
Attach the actual data. Maybe a 1/x curve will be better.

Melden Sie sich an, um zu kommentieren.

### Weitere Antworten (1)

Matt J am 18 Aug. 2017
For a simple pinhole camera model (and ignoring off-axis effects), the relationship between distance and perimeter (in pixels) should be
distance=K/perimeter
Just fit the constant K with as many (perimeter,distance) measurements that you have.
##### 1 KommentarKeine anzeigenKeine ausblenden
Alla am 21 Aug. 2017
Thanks Matt
My problem is both practical than conceptual,my goal is to have a good range estimator that relies on thresholding those objects, I'm not sure if this is the best way to do it or not but I am giving it a shot, now I'm struggling with getting it to work, it might be very simple for you but unfortunately I'm not the best at this stuff

Melden Sie sich an, um zu kommentieren.

### Kategorien

Find more on Logical in Help Center and File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!