感兴趣区域的坐标

时间:2019-07-26 18:19:30

标签: python opencv image-processing

我正在使用Python开发OpenCV;用于眼周区域检测和提取眼周区域。我正在使用SVM检测眼周区域。该模型预测的很好。我要在预测眼周区域后;它将从图像中提取“眼睛坐标”。

import cv2

import numpy as np
#import svm

svm = cv2.ml.SVM_load("C:\\Users\\ATech\\AppData\\Local\\Programs\\Python\\Python37-32\\interface\\images\\svm_training1.xml")
sample = []
img = cv2.imread("C:\\Users\\ATech\\AppData\\Local\\Programs\\Python\\Python37-32\\interface\\images\\1.jpg")
#img = cv2.resize(img, (240, 160))
eye_cascade=cv2.CascadeClassifier("haarcascade_eye.xml")

eyes = eye_cascade.detectMultiScale(img, scaleFactor = 1.1, minNeighbors = 5)


for(ex,ey,ew,eh)in eyes:

    #image=cv2.resize(image, (240, 160))
    img=cv2.rectangle(image,(ex,ey),(ex+ew,ey+eh),(255,0,0),6)



cv2.imshow("image",img)
hog = cv2.HOGDescriptor()
hist = hog.compute(img)
sample.append(hist)
sample = np.float32(sample)
#hist = cv2.resize(hist, (1, 1))
res = svm.predict(sample)
print (res)

0 个答案:

没有答案