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?
1 | initial version |
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?
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?
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?
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?
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?
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?background?!(https://drive.google.com/file/d/1aoAV0RejHMcsBh4IvOlMHR02_rqEGfEB/view?usp=drivesdk)
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)
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)
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?
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?
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()