简体   繁体   English

图像中的红色坐标

[英]Red color coordinate in image

I am unable to get the coordinates of the red point in the following image.我无法获得下图中红点的坐标。

image1.png

image = cv2.imread('image1.png')
lower_red = np.array([0,0,220])

upper_red = np.array([10,10,255])

mask = cv2.inRange(image, lower_red, upper_red)
coord=cv2.findNonZero(mask)

I am getting error in line 4.我在第 4 行遇到错误。

error: OpenCV(4.1.0) C:\projects\opencv-python\opencv\modules\core\src\arithm.cpp:1726: error: (-215:Assertion failed).错误:OpenCV(4.1.0) C:\projects\opencv-python\opencv\modules\core\src\arithm.cpp:1726:错误:(-215:断言失败)。 _src:empty() in function 'cv::inRange' _src:empty() 在 function 'cv::inRange'

Enter the absolute path of the image file.输入图像文件的绝对路径。 It will fix this issue.它将解决此问题。 Later, you can print the coordinates of the red colour by printing value of coord .稍后,您可以通过打印coord的值来打印红色的坐标。

When i tried printing coord , It gave me the following output-当我尝试打印coord时,它给了我以下输出-

[[[211 552]]

 [[212 552]]

 [[213 552]]

 ...

 [[215 586]]

 [[216 586]]

 [[217 586]]]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM