Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How can we calculate length/width of an object in image?

Basically , i am trying to calculate length/width of an object in image ,with cartesian graph paper in background.I have found bounding box of object.But how can i read cartesian coordinate (x,y) in background?image description

How can we calculate length/width of an object in image?

Basically , i am trying to calculate length/width of an object in image ,with cartesian graph paper in background.I have found bounding box of object.But how can i read cartesian coordinate (x,y) in background?image description

How can we calculate length/width of an object in image?

Basically , i am trying to calculate length/width of an object in image ,with cartesian graph paper in background.I have found bounding box of object.But how can i read cartesian coordinate (x,y) in background?image description

How can we calculate length/width of an object in image?

Basically , i am trying to calculate length/width of an object in image ,with cartesian graph paper in background.I have found bounding box of object.But how can i read cartesian coordinate (x,y) in background?image description

How can we calculate length/width of an object in image?

Basically , i am trying to calculate length/width of an object in image ,with cartesian graph paper in background.I have found bounding box of object.But how can i read cartesian coordinate (x,y) in background?image description

How can we calculate length/width of an object in image?

Basically , i am trying to calculate length/width of an object in image ,with cartesian graph paper in background.I have found bounding box of object.But how can i read cartesian coordinate (x,y) in background?image descriptionbackground?!(https://drive.google.com/file/d/1aoAV0RejHMcsBh4IvOlMHR02_rqEGfEB/view?usp=drivesdk)

How can we calculate length/width of an object in image?

Basically , i am trying to calculate length/width of an object in image ,with cartesian graph paper in background.I have found bounding box of object.But how can i read cartesian coordinate (x,y) in background?!(https://drive.google.com/file/d/1aoAV0RejHMcsBh4IvOlMHR02_rqEGfEB/view?usp=drivesdk)background?

(https://drive.google.com/file/d/1aoAV0RejHMcsBh4IvOlMHR02_rqEGfEB/view?usp=drivesdk)

How can we calculate length/width of an object in image?

Basically , i am trying to calculate length/width of an object in image ,with cartesian graph paper in background.I have found bounding box of object.But how can i read cartesian coordinate (x,y) in background?

(https://drive.google.com/file/d/1aoAV0RejHMcsBh4IvOlMHR02_rqEGfEB/view?usp=drivesdk)

How can we calculate length/width of an object in image?

Basically , i am trying to calculate length/width of an object in image ,with cartesian graph paper in background.I have found bounding box of object.But how can i read cartesian coordinate (x,y) in background?

(https://drive.google.com/file/d/1aoAV0RejHMcsBh4IvOlMHR02_rqEGfEB/view?usp=drivesdk)background? image description

How can we calculate length/width of an object in image?

Basically , i am trying to calculate length/width of an object in image ,with cartesian graph paper in background.I have found bounding box of object.But how can i read cartesian coordinate (x,y) in background? image description


    import cv2 as cv
import numpy as np
img = cv.imread('E:\PY_CV\graph1.jpg')
img=cv.resize(img,(400,400))
edges = cv.Canny(img,100,200)
####################################
# Convert BGR to HSV https://www.lifewire.com/what-is-hsv-in-design-1078068
hsv_g = cv.cvtColor(img, cv.COLOR_BGR2HSV)
# define range of green color in HSV
lower_green = np.array([30,60,60])
upper_green = np.array([100,255,255])
# Threshold the HSV image to get only yellow colors
mask_g = cv.inRange(hsv_g, lower_green, upper_green)
non_zero_green=cv.countNonZero(mask_g)
points=cv.findNonZero(mask_g)
x,y,w,h=cv.boundingRect(points)
cv.rectangle(img,(x,y),(x+w,y+h),(255,255,255),2)
cropped_green=img[y:y+h,x:x+w]
print(x)
print(y)
print(w)
print(h)
cv.imshow('mask-green',mask_g)
cv.imshow('cropped_green',cropped_green)
cv.imshow('bounding_box',img)
cv.waitKey(0)
cv.destroyAllWindows()