Erkennen Sie den farbigen Kreis und die Mitte mit OpenCVPython

Python-Programme
Guest
 Erkennen Sie den farbigen Kreis und die Mitte mit OpenCV

Post by Guest »

Ich versuche, einen blauen Kreis zu erkennen und es ist Mitte. Zeichnen Sie dann einen Kreis auf den erkannten Kreis und einen sehr kleinen Kreis in der Mitte. Aber ich bekomme ein paar Fehler. (Ich verwende OpenCV 3.1.0, Python 2.7 Anaconda 64 Bit, Pycharm als IDE) (Bitte helfen Sie mir, Python -Codes zu verwenden) import cv2
import numpy as np

cap = cv2.VideoCapture(0)
if cap.isOpened():
while(True):
frame, _ = cap.read()
# blurring the frame that's captured
frame_gau_blur = cv2.GaussianBlur(frame, (3, 3), 0)
# converting BGR to HSV
hsv = cv2.cvtColor(frame_gau_blur, cv2.COLOR_BGR2HSV)
# the range of blue color in HSV
lower_blue = np.array([110, 50, 50])
higher_blue = np.array([130, 255, 255])
# getting the range of blue color in frame
blue_range = cv2.inRange(hsv, lower_blue, higher_blue)
# getting the V channel which is the gray channel
blue_s_gray = blue_range[::2]
# applying HoughCircles
circles = cv2.HoughCircles(blue_s_gray, cv2.HOUGH_GRADIENT, 1, 10, 100, 30, 5, 50)
circles = np.uint16(np.around(circles))
for i in circles[0,:]:
# drawing on detected circle and its center
cv2.circle(frame,(i[0],i[1]),i[2],(0,255,0),2)
cv2.circle(frame,(i[0],i[1]),2,(0,0,255),3)
cv2.imshow('circles', frame)
k = cv2.waitKey(5) & 0xFF
if k == 27:
break
cv2.destroyAllWindows()
else:
print "Can't find camera"
< /code>
Der Fehler, den ich erhalte, wenn ich den Code ausführe, lautet: < /p>

openCV -Fehler: Behauptung fehlgeschlagen C: \ Builds \ master_packslaveaddon-win64-vc12-static \ opencv \ module \ imgproc \ src \ color.cpp, Zeile 7935
TracBack (letztes Anruf):
Datei "C: /Users/Meliodas/pycharmprojects/opencv_by_examples/code_tester.py", Zeile 11, in
hsv = cv2.cvtcolor (Fram_gau_blur, cv2.color_bgr2hsv)
cv2.Err. C: \ Builds \ master_packslaveaddon-win64-vc12-static \ opencv \ module \ imgproc \ src \ color.cpp: 7935: Fehler: (-215) Tiefe == CV_8U || Tiefe == CV_16U || Tiefe == CV_32F in Funktion cv :: cvtcolor
Vielen Dank im Voraus für Ihre Hilfe!

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post