Code Monkey home page Code Monkey logo

distancedetect's Introduction

DistanceDetect


实验目的

使用opencv实现对特定物体进行初步的标定并实现对物体进行距离检测

基本原理

用相似三角形的原理计算物体或者目标到相机的距离。相似三角形原理,即在某个已知摄像头距离的条件下先计算出摄像头的焦距:F = (P x D) / W,P为照片中物体宽度的像素长度,D为已知距离,W为已知物体实际宽度,假设我在离相机距离 D = 32 cm的地方放一张标准的白色纸(横着放,W = 25.5cm)并且拍下一张照片。我测量出照片中白纸的像素宽度为 P = 520 像素。因此我的焦距 F 是:F = (520px x 32cm) / 25.5cm = 652.54,当我继续将我的相机移动靠近或者离远物体或者目标时,我可以用相似三角形来计算出物体离相机的距离:D’ = (W x F) / P。

实验使用图片

为方便对待测量物体进行标定和选择,我将测量物体定为白纸,并将其放置在黑色鞋盒上,方便边缘提取以及二值化处理,并拍摄一张已知物体距离(32cm)的照片用于计算焦距,再分别拍摄了2张约距离分别为50cm和70cm的照片用来作为待测照片。

实验效果

distancedetect's People

Contributors

jokieleung avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.