Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
9644e88
Updating README, adding Discription of #FocalLength Function
Mar 25, 2021
9a52369
Updating README, adding Discription of #FocalLength Function
Mar 25, 2021
2d103bd
Updating README #Distance_finder function adding #Social-Media links
Mar 25, 2021
6384ca5
adding #icons social Media
Mar 25, 2021
9cb5911
adding #Updated_distance.py , adding #animated Gif to README
Mar 25, 2021
b39bdc7
#solved Unit miss matching #bug
Mar 26, 2021
e65b8c6
Updating #youtube video link FFRobot, adding other information
Mar 26, 2021
7b6ab6a
updating Readme
Mar 26, 2021
f072f5a
udpadating readme and adding Animated gif
Mar 26, 2021
9455d8f
udpadating readme and adding Animated gif
Mar 26, 2021
fdb6712
udpadating readme and adding Animated gif
Mar 26, 2021
3392044
udpadating readme and adding Animated gif
Mar 26, 2021
bc98efd
udpadating readme and adding Animated gif
Mar 26, 2021
5950042
adding icons and animated gif
Mar 26, 2021
792bfa4
Merge pull request #2 from Asadullah-Dal17/changes
Mar 26, 2021
2273634
adding doc String #function Description
Mar 26, 2021
82c5592
Updating readme
Mar 26, 2021
d932c40
updating readme
Apr 19, 2021
6be7e83
making it look good
Apr 19, 2021
4a4ba91
adding speed functionlty
Apr 23, 2021
1d6b163
adding speed functionlty
Apr 23, 2021
c2820b4
adding speed functionlty
Apr 23, 2021
ffb6b66
finding Speed
Apr 23, 2021
048356f
finding speed done, need some improvement
Apr 23, 2021
dce5361
adding readme to the speed directory
Apr 23, 2021
c6d931c
adding speed functionlity to code
Apr 30, 2021
5059d82
updating readme file
Apr 30, 2021
3e3c598
found the speed
Apr 30, 2021
0cacca5
adding speed.py, correct indentation problem on distance.py
Apr 30, 2021
b59c16b
Merge pull request #3 from Asadullah-Dal17/Speed
Apr 30, 2021
dc013d0
adding speed.py code
May 3, 2021
e43dac8
Merge pull request #4 from Asadullah-Dal17/Speed
May 3, 2021
fb109c2
updating speed.py
May 5, 2021
21ffdb3
Merge pull request #5 from Asadullah-Dal17/Speed
May 5, 2021
b7537bd
adding image speed and distance
May 7, 2021
c9d0c02
Merge pull request #6 from Asadullah-Dal17/Speed
May 7, 2021
54d35c7
updating readme of speed
May 7, 2021
17549fd
updating readme of speed
May 7, 2021
1213dac
Merge pull request #7 from Asadullah-Dal17/Speed
May 7, 2021
86598a8
updating readme distance.py
May 7, 2021
ac5823c
Merge pull request #8 from Asadullah-Dal17/Speed
May 7, 2021
86987d7
udating git readme
May 28, 2021
a206d31
updating readme file
May 31, 2021
50a1bc3
updating readme file
May 31, 2021
92c6ffe
updating readme file
May 31, 2021
94c9d1d
adding yolo objector files and README
Jun 1, 2021
54f911c
updating code
Jun 1, 2021
061d9bc
Merge pull request #9 from Asadullah-Dal17/YoloObjectDetector
Jun 1, 2021
bbb351f
object detection done, yolov4
Jun 1, 2021
62cf114
Merge pull request #10 from Asadullah-Dal17/YoloObjectDetector
Asadullah-Dal17 Jun 1, 2021
8e37b06
adding capture reference image script
Jun 1, 2021
f8af848
Merge pull request #11 from Asadullah-Dal17/YoloObjectDetector
Asadullah-Dal17 Jun 1, 2021
7f7d30d
updating distance finder yolo with yolo object detector
Jun 2, 2021
08a5da8
updating distance estimation, uisng yolo is complete :heavy_check_mark:
Jun 4, 2021
b796630
updating readme file
Jun 4, 2021
3828f68
Merge pull request #12 from Asadullah-Dal17/YoloObjectDetector
Asadullah-Dal17 Jun 4, 2021
5684d8f
udpating yolo4.py
Jun 6, 2021
ca6cda3
updating yolov4.py displaying distance
Jun 7, 2021
3d5ee76
Merge pull request #13 from Asadullah-Dal17/YoloObjectDetector
Asadullah-Dal17 Jun 7, 2021
71c7881
updating readme file
Jun 7, 2021
a252758
Merge pull request #14 from Asadullah-Dal17/YoloObjectDetector
Asadullah-Dal17 Jun 7, 2021
ed20842
Adding Demo video Github Readme
Asadullah-Dal17 Jun 19, 2021
c732d14
updating readme, distance and speed estimation, deleting GIF files
Jun 19, 2021
6a0ad43
updating file
Asadullah-Dal17 Jun 20, 2021
8addb12
updating code for adding more classes in yolov4
Asadullah-Dal17 Jul 1, 2021
5d0b1ce
updating code for adding more classes in yolov4
Asadullah-Dal17 Jul 1, 2021
fc73f52
updating code for adding more classes in yolov4
Asadullah-Dal17 Jul 1, 2021
ed64e1f
updating code for adding more classes in yolov4
Asadullah-Dal17 Jul 1, 2021
b967e2d
updating code
Asadullah-Dal17 Jul 4, 2021
6f60339
coding proctcols, following changes, like constant, function names
Asadullah-Dal17 Jul 4, 2021
d5fa82b
updating github readme on the base changes in distance.py
Asadullah-Dal17 Jul 4, 2021
f7e6bba
Merge pull request #17 from Asadullah-Dal17/conventiontChanges
Asadullah-Dal17 Jul 4, 2021
43a8488
updating readme, adding yolov4 distance estimation demo
Asadullah-Dal17 Jul 8, 2021
9927ea9
Merge pull request #18 from Asadullah-Dal17/conventiontChanges
Asadullah-Dal17 Jul 8, 2021
b84442f
remove yolov4 implementationfrom here
Asadullah-Dal17 Jul 8, 2021
05fbdfd
updating readme file
Asadullah-Dal17 Jul 13, 2021
1ad5e14
removing vscode dir
Asadullah-Dal17 Jul 13, 2021
d620ced
updating readme file
Asadullah-Dal17 Jul 13, 2021
23bb270
fixed Issue #2
Asadullah-Dal17 Jul 27, 2021
5becb92
udpating readme file, adding social links
Asadullah-Dal17 Sep 18, 2021
cc1e7a3
updating files
Asadullah-Dal17 Oct 1, 2021
87438dc
Update README.md
Asadullah-Dal17 Oct 1, 2021
1f02125
adding Readme file
Asadullah-Dal17 Oct 20, 2021
738ef00
adding distance estimation for pi, USB Camera
Asadullah-Dal17 Oct 20, 2021
93d2c4e
updating path of files
Asadullah-Dal17 Oct 20, 2021
7ec86cc
adding installtion guide line for opencv on Pi
Asadullah-Dal17 Oct 20, 2021
1ce7e62
adding FPS to the script
Asadullah-Dal17 Oct 20, 2021
faeeed7
adding AiPhile Script
Asadullah-Dal17 Oct 20, 2021
d3375b0
adding better representation of text
Asadullah-Dal17 Oct 20, 2021
a9bcd55
fixding :bug:
Asadullah-Dal17 Oct 20, 2021
37d3289
updating the position of text
Asadullah-Dal17 Oct 20, 2021
418c7ec
updating distance.py, adjusting text, to look good
Asadullah-Dal17 Oct 20, 2021
bfa9651
adding pi camera, code :warning: code not test yet on pi cam, hopfull…
Asadullah-Dal17 Oct 20, 2021
e6fc8dd
udpdating file
Asadullah-Dal17 Oct 20, 2021
73f2926
updating file
Asadullah-Dal17 Oct 20, 2021
3181a45
adding Raspberry pi Distance Estimation Video
Asadullah-Dal17 Oct 21, 2021
6a31714
correcting spelling
Asadullah-Dal17 Oct 21, 2021
6884be3
Update README.md
Asadullah-Dal17 Oct 21, 2021
cfa0a66
Update README.md
Asadullah-Dal17 Oct 21, 2021
e832f4b
Update README.md
Asadullah-Dal17 Oct 21, 2021
d388f25
updating README
Asadullah-Dal17 Dec 23, 2021
24a79ba
formating code
Asadullah-Dal17 Jan 9, 2022
c5ae0bb
Merge branch 'main' of github.com:Asadullah-Dal17/Distance_measuremen…
Asadullah-Dal17 Jan 9, 2022
3dcf25b
formating code
Asadullah-Dal17 Jan 9, 2022
1564e3b
formating file
Asadullah-Dal17 Jan 9, 2022
67415a9
formating file
Asadullah-Dal17 Jan 9, 2022
981be7a
adding fiverr account details
Asadullah-Dal17 May 7, 2022
c3bcc5e
Update README.md
Asadullah-Dal17 Oct 31, 2023
3b13d78
Update README.md
Asadullah-Dal17 Dec 8, 2023
935df1b
Update README with project details and links
Asadullah-Dal17 Nov 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.mp4
124 changes: 62 additions & 62 deletions Capture_Reference_image/Capture_Reference_Image.py
Original file line number Diff line number Diff line change
@@ -1,63 +1,63 @@

import cv2
import time
import os
# chose your camera number:
cam_number =2
camera = cv2.VideoCapture(cam_number)
starting_time =time.time()
Frame_Counter= 0
Cap_frame =0
Dir_name = "capture_images"
number_image_captured =20
capture_image=False
while True:
# checking the Directory Exist or not .
IsDirExist = os.path.exists(Dir_name)
print(IsDirExist)
# if there is no Directory named "capture_image", simply create it. using os
if not IsDirExist:
os.mkdir(Dir_name)

Frame_Counter+=1
# reading the frames from camera
ret, frame = camera.read()
# reading saving frame seperatly
ret, saving_frame = camera.read()
# finding with and height of image
height, width, dim = saving_frame.shape
# print(width, height, dim)

# writing the width and height of on the image saving image
cv2.putText(saving_frame, f"Height: {height}", (30, 50), cv2.FONT_HERSHEY_COMPLEX, 0.4, (0,255,0),1)
cv2.putText(saving_frame, f"Width: {width}", (30, 70), cv2.FONT_HERSHEY_COMPLEX, 0.4, (0,255,0),1)
# capture frame if capture_image is ture and number_image_captured are less then 10
# if we press 'c' on keyboard then capture_image become 'True'
if capture_image==True and Cap_frame <= number_image_captured:
Cap_frame+=1
cv2.putText(frame, 'Capturing', (50, 70), cv2.FONT_HERSHEY_COMPLEX, 2, (0,244, 255),1)
cv2.imwrite(f"{Dir_name}/frame-{Cap_frame}.png", saving_frame)
else:
cv2.putText(frame, 'Not Capturing', (50, 70), cv2.FONT_HERSHEY_COMPLEX, 2, (255,0, 255),1)
Cap_frame =0
capture_image =False
cv2.imshow("frame", frame)
cv2.imshow("saving Image", saving_frame)
total_time = time.time()
frame_time=total_time -starting_time
# calculating how much frame pass in each second

fps = Frame_Counter/frame_time
# print(fps)
# print(capture_image)
# when we press 'q' it quites the program
if cv2.waitKey(1) == ord('q'):
break
# if we press 'c' on the keyboard then it starts capturing the images.
if cv2.waitKey(1)==ord('c'):
capture_image= True

# finally closing the camera
camera.release()
# closing all opend windows
import cv2
import time
import os
# chose your camera number:
cam_number =2
camera = cv2.VideoCapture(cam_number)
starting_time =time.time()
Frame_Counter= 0
Cap_frame =0
Dir_name = "capture_images"
number_image_captured =20
capture_image=False
while True:
# checking the Directory Exist or not .
IsDirExist = os.path.exists(Dir_name)
print(IsDirExist)
# if there is no Directory named "capture_image", simply create it. using os
if not IsDirExist:
os.mkdir(Dir_name)
Frame_Counter+=1
# reading the frames from camera
ret, frame = camera.read()
# reading saving frame seperatly
ret, saving_frame = camera.read()
# finding with and height of image
height, width, dim = saving_frame.shape
# print(width, height, dim)
# writing the width and height of on the image saving image
cv2.putText(saving_frame, f"Height: {height}", (30, 50), cv2.FONT_HERSHEY_COMPLEX, 0.4, (0,255,0),1)
cv2.putText(saving_frame, f"Width: {width}", (30, 70), cv2.FONT_HERSHEY_COMPLEX, 0.4, (0,255,0),1)
# capture frame if capture_image is ture and number_image_captured are less then 10
# if we press 'c' on keyboard then capture_image become 'True'
if capture_image==True and Cap_frame <= number_image_captured:
Cap_frame+=1
cv2.putText(frame, 'Capturing', (50, 70), cv2.FONT_HERSHEY_COMPLEX, 2, (0,244, 255),1)
cv2.imwrite(f"{Dir_name}/frame-{Cap_frame}.png", saving_frame)
else:
cv2.putText(frame, 'Not Capturing', (50, 70), cv2.FONT_HERSHEY_COMPLEX, 2, (255,0, 255),1)
Cap_frame =0
capture_image =False
cv2.imshow("frame", frame)
cv2.imshow("saving Image", saving_frame)
total_time = time.time()
frame_time=total_time -starting_time
# calculating how much frame pass in each second
fps = Frame_Counter/frame_time
# print(fps)
# print(capture_image)
# when we press 'q' it quites the program
if cv2.waitKey(1) == ord('q'):
break
# if we press 'c' on the keyboard then it starts capturing the images.
if cv2.waitKey(1)==ord('c'):
capture_image= True
# finally closing the camera
camera.release()
# closing all opend windows
cv2.destroyAllWindows()
108 changes: 54 additions & 54 deletions Capture_Reference_image/Distance_Measurement.py
Original file line number Diff line number Diff line change
@@ -1,54 +1,54 @@
import cv2 as cv


# data
Know_distance =30 # in centimeters
#mine is 14.3 something, measure your face width, are google it
Know_width_face =14.3 #centimeters
# chose your camera
cam_number =1
face_detector = cv.CascadeClassifier('data/haarcascade_frontalface_default.xml')
camera = cv.VideoCapture(cam_number)
def FocalLengthFinder(Measured_distance, real_width_of_face, width_of_face_in_image):
# finding focal length
focal_length = (width_of_face_in_image* Measured_distance)/real_width_of_face
return focal_length

def Distance_Measurement(face_real_width, Focal_Length, face_with_in_image):
distance= (face_real_width * Focal_Length)/face_with_in_image
return distance
def Face_Detection(image):
f_width =0
Gray_image = cv.cvtColor(image, cv.COLOR_BGR2GRAY)
faces = face_detector.detectMultiScale(Gray_image, 1.3, 5)
for (x, y, h, w) in faces:
cv.rectangle(image, (x,y), (x+w, y+h), (255,255,255), 1)
f_width =w
print(f_width)
return f_width, image
reference_image =cv.imread("rf.png")
face_w , image_read= Face_Detection(reference_image)
cv.imshow("ref", image_read)
calculate_focal_length =FocalLengthFinder(Know_distance, Know_width_face,face_w)
print(calculate_focal_length)
font = cv.FONT_HERSHEY_SIMPLEX
while True:
ret, frame = camera.read()
height, width, dim = frame.shape
# change the color of image
# print(height, width)
Gray_image = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
faces = face_detector.detectMultiScale(Gray_image, 1.3, 5)
for (x, y, h, w) in faces:
cv.rectangle(frame, (x,y), (x+w, y+h), (255,255,255), 1)
distance =Distance_Measurement(Know_width_face,calculate_focal_length, w)
print(distance)

cv.putText(frame, f" Distance = {distance}", (50,50),font, 0.7, (0,255,0), 3)

cv.imshow('frame', frame)

if cv.waitKey(1)==ord('q'):
break
camera.release()
cv.destroyAllWindows()
import cv2 as cv
# data
Know_distance =30 # in centimeters
#mine is 14.3 something, measure your face width, are google it
Know_width_face =14.3 #centimeters
# chose your camera
cam_number =1
face_detector = cv.CascadeClassifier('data/haarcascade_frontalface_default.xml')
camera = cv.VideoCapture(cam_number)
def FocalLengthFinder(Measured_distance, real_width_of_face, width_of_face_in_image):
# finding focal length
focal_length = (width_of_face_in_image* Measured_distance)/real_width_of_face
return focal_length
def Distance_Measurement(face_real_width, Focal_Length, face_with_in_image):
distance= (face_real_width * Focal_Length)/face_with_in_image
return distance
def Face_Detection(image):
f_width =0
Gray_image = cv.cvtColor(image, cv.COLOR_BGR2GRAY)
faces = face_detector.detectMultiScale(Gray_image, 1.3, 5)
for (x, y, h, w) in faces:
cv.rectangle(image, (x,y), (x+w, y+h), (255,255,255), 1)
f_width =w
print(f_width)
return f_width, image
reference_image =cv.imread("rf.png")
face_w , image_read= Face_Detection(reference_image)
cv.imshow("ref", image_read)
calculate_focal_length =FocalLengthFinder(Know_distance, Know_width_face,face_w)
print(calculate_focal_length)
font = cv.FONT_HERSHEY_SIMPLEX
while True:
ret, frame = camera.read()
height, width, dim = frame.shape
# change the color of image
# print(height, width)
Gray_image = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
faces = face_detector.detectMultiScale(Gray_image, 1.3, 5)
for (x, y, h, w) in faces:
cv.rectangle(frame, (x,y), (x+w, y+h), (255,255,255), 1)
distance =Distance_Measurement(Know_width_face,calculate_focal_length, w)
print(distance)
cv.putText(frame, f" Distance = {distance}", (50,50),font, 0.7, (0,255,0), 3)
cv.imshow('frame', frame)
if cv.waitKey(1)==ord('q'):
break
camera.release()
cv.destroyAllWindows()
Loading