私は目の瞳孔を検出する必要がある目の制御された車椅子のプロジェクトを持っています。私が書いているコードのテストとして、私は静止画像上でスクリプトを実行しました。画像はカメラが置かれる場所です。カメラはIRカメラになります。ハフ・サークル・トランスフォームを使用した目の瞳孔追跡
注:後
:私はWindowsのPlatfrom
私はHoughcircle変換を用いて欲しかっ検出した円上でコンパイルOpenCVの3.1.0-devのとPython2.7を使用しています IRカメラを使うだけで同じことを検出するコードを作っているということです。
静止画像コードの結果は私にとっては非常に信頼できますが、問題はIRカメラのコードです。
私がこれまで書いてきたコードは次のとおりです。静的なイメージのためのコードについてのご質問については
import cv2
import numpy as np
cap = cv2.VideoCapture(0)
while True:
## Read Image
ret, image = cap.read()
## Convert to 1 channel only grayscale image
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
## CLAHE Equalization
cl1 = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8,8))
clahe = cl1.apply(gray)
## medianBlur the image to remove noise
blur = cv2.medianBlur(clahe, 7)
## Detect Circles
circles = cv2.HoughCircles(blur ,cv2.HOUGH_GRADIENT,1,20,
param1=50,param2=30,minRadius=7,maxRadius=21)
if circles != None:
circles = np.round(circles[0,:]).astype("int")
for circle in circles[0,:]:
# draw the outer circle
cv2.circle(image,(circle[0],circle[1]),circle[2],(0,255,0),2)
# draw the center of the circle
cv2.circle(image,(circle[0],circle[1]),2,(0,0,255),3)
if cv2.waitKey(1) in [27, ord('q'), 32]:
break
cap.release()
cv2.destroyAllWindows()
I always get this error:
**if circles != None:
FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.
Traceback (most recent call last):
cv2.circle(image,(circle[0],circle[1]),circle[2],(0,255,0),2)
IndexError: invalid index to scalar variable.**
、コードは次のとおりです。
import cv2
import numpy as np
## Read Image
image = cv2.imread('eye.tif')
imageBackup = image.copy()
## Convert to 1 channel only grayscale image
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
## CLAHE Equalization
cl1 = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8,8))
clahe = cl1.apply(gray)
## medianBlur the image to remove noise
blur = cv2.medianBlur(clahe, 7)
## Detect Circles
circles = cv2.HoughCircles(blur ,cv2.HOUGH_GRADIENT,1,20,
param1=50,param2=30,minRadius=7,maxRadius=21)
for circle in circles[0,:]:
# draw the outer circle
cv2.circle(image,(circle[0],circle[1]),circle[2],(0,255,0),2)
# draw the center of the circle
cv2.circle(image,(circle[0],circle[1]),2,(0,0,255),3)
cv2.imshow('Final', image)
cv2.imshow('imageBackup', imageBackup)
cv2.waitKey(0)
cv2.destroyAllWindows()
IRカメラの問題は何ですか?それは何か円を見つけるか、まったく何も見つけませんか?サンプル画像を提供できますか? – PSchn
@PSchnカメラに問題はありませんが、円が検出されない場合、PythonスクリプトでNoneTypeエラーが発生するという問題があります。私はこれを質問に入れなければならない。 – Tes3awy
エラーメッセージも追加してください。 – PSchn