开发者

eye tracking driven vitual computer mouse using OpenCV python lkdemo

开发者 https://www.devze.com 2023-02-24 10:02 出处:网络
I am a beginner in OpenCV programming. Now I\'m trying to develop an eye tracking driven virtual computer mouse using OpenCV python version of lkdemo. I have a code in python lkdemo. I compiled it usi

I am a beginner in OpenCV programming. Now I'm trying to develop an eye tracking driven virtual computer mouse using OpenCV python version of lkdemo. I have a code in python lkdemo. I compiled it using python pgmname.py.Then I have the following results.

OpenCV Python version of lkdemo
Traceback (most recent call last):
  File "test.py", line 64, in <module>
    capture = cvCreateCameraCapture (device)
NameError: name 'cvCreateCameraCapture' is not defined.  

Can anyone help to solve this?

Update: now the error is:

OpenCV Python version of lkdemo
Traceback (most recent call last):
  File "test.py", line 8, in <module>
    import cv
ImportError: No mod开发者_如何学运维ule named cv

Can anyone suggest a solution?


The API changed a while ago. Depending on your version, it should rather be something like:

import cv
capture = cv.CaptureFromCAM(0)
img = cv.QueryFrame(capture)

HTH.


what is your version OpenCV? this example for version 2.4.5:

import cv2
import numpy as np
c = cv2.VideoCapture(0)

while(1):
    _,f = c.read()
    cv2.imshow('e2',f)
    if cv2.waitKey(5)==27:
        break
cv2.destroyAllWindows()
0

精彩评论

暂无评论...
验证码 换一张
取 消