如何修改这个python opencv程序来从阈值图像中获取xy坐标
How to modify this python opencv program to get xy coordinates from thresholded image
我有一个opencv程序来跟踪一个蓝色的对象
有人可以修改它,找到从摄像头跟踪的对象的中心阈值后,它的二值图像
PS:我希望这个程序与网络摄像头一起工作,而不是图像
import numpy as np
import cv2
cap = cv2.VideoCapture(1)
while(True):
ret, frame = cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
lower_blue = np.array([110,50,50])
upper_blue = np.array([130,255,255])
mask = cv2.inRange(gray, lower_blue, upper_blue)
res = cv2.bitwise_and(frame,frame, mask= mask)
# Display the resulting frame
cv2.imshow('frame',gray)
cv2.imshow('mask',mask)
cv2.imshow('res',res)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()
我想从网络摄像头的阈值图像中找到白色斑点的中心xy坐标
我有代码,我用来寻找阈值图像的xy坐标
我想修改它从网络摄像头的实时视频
下面是查找二进制图像坐标的代码
for y in xrange(img.size[1]):
for x in xrange(img.size[0]):
if pixels[x, y] == 0:
xlist.append(x)
ylist.append(y)
xleft = min(xlist)
xright = max(xlist)
ytop = min(ylist)
ybot = max(ylist)
xax = (xleft+xright)/2
yax = (ytop+ybot)/2
有人能把这两个代码结合起来,使它可以从网络摄像头的实时饲料
你想在bitwise_and之后找到contours,然后获得轮廓的boundingRect(或矩)以获得x,y位置。
,忘记你的"查找二值图像的坐标"的想法。(不,你不想要重新发明"连接组件"。使用内置的东西代替)
相关文章:
- 传感器值的阈值
- 我们可以将阈值应用于色彩空间模型的单个组件(如 RGB 和 LAB)吗?
- 错误:断言失败 (src.type() == CV_8UC1) 在阈值中
- 使用阈值进行加速度计振动检测
- OpenCV Otsu的阈值:计算多个Mat对象的单个阈值
- Java opencv inRange 阈值函数将我的图像分成三个不同的图像
- 在RGB图像上执行阈值操作
- NDK-图像阈值
- 如何在 OpenCv 中使用 HSV 阈值和轮廓从图像中提取皮肤
- 如何访问cv::canny阈值的梯度幅度图像
- OpenCV:如何使用阈值正确分割图像/使用二进制图像对原始图像进行分割
- 使用 VTK (vtkImageThreshold) 的阈值图像数据
- 如何使阈值窗口仅适用于我的一半图像
- 在一定范围内对图像进行阈值设置
- OpenCV:设置图像阈值并反转图像
- 在阈值图像中查找行间距- R/ c++图像处理
- 在rgb图像上应用二值阈值滤波器
- opencvc++在阈值图像中查找移动
- 二维哈尔小波变换软阈值图像去噪(c++)
- 如何修改这个python opencv程序来从阈值图像中获取xy坐标