Giter VIP home page Giter VIP logo

distance-between-camera-and-object's Introduction

Distance-between-camera-and-objects

Thr objects are assumed to be chess piece The two primary parts of the code are Detecting the chess piece which has the most lines of code and measuring the distance

Detecting chess piece

“cv2.cvtColor(image, cv2.COLOR_BGR2HSV)” -Image converted to HSV color model “Gra[:,:,2]” - Converted to black and white. The 2 signifies black and white. “v2.GaussianBlur(gray, (7,7), 0)” - Blur the image in order to better detect image. “cv2.inRange(gray, 0, 70)” Select black pixels denoted by range from 0 to 70. This is the background of chess piece. The chess piece is in white color. The gaps in the background need to be filled. This is done by repeating dilation and erosion. In Dilation, the value of the output pixel is the maximum value of all the pixels in the input pixel's neighborhood. In a binary image, if any of the pixels is set to the value 1, the output pixel is set to 1. In Erosion, the value of the output pixel is the minimum value of all the pixels in the input pixel's neighborhood. In a binary image, if any of the pixels is set to 0, the output pixel is set to 0. “np.where(edged>50)”-Select the chess piece by selecting all white pixels

Measuring distance between Chess piece.

In the variable ‘ff’ all pixels of the detected chess piece are stored. The average of all pixels of chess piece is found by using the mean function to find the centre of the chess piece The distance is found by using Euclidian distance formula. dist((x, y), (a, b)) = Squareroot((x - a)² + (y - b)²) Where x,y are x and y coordinates of centre of first chess piece. Similarly a,b are x and y coordinates of centre of second chess piece.

Distance betwen Camera and Object The distace or pixels between object in 2 images is inversely proportional to distace between camera and object. HEnce the constant pf proportionality is calculated and stored in text. T

Executing the file

In the first line of Calibrate file , you will need to set the distance between chess pieces of two images. This is needed to calibrate the camera each time camera position is changed When you calibrate , new file called donotdelete.txt will be generated. Then run calculate file. The distance will be shown :)

distance-between-camera-and-object's People

Contributors

agnelvishal avatar

Watchers

 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.