Ayesha Khan
Ayesha Khan

Reputation: 43

Error: QueryFrame not a member of cv

When I run my opencv code on raspbian i get the following error:

error: "CaptureFromCAM" is not a member of cv
error: "SetCaptureProperty" is not a member of cv
error: "QueryFrame" is not a member of cv

Can anyone help with the correct notations as I am using opencv 3.0. The code runs without errors on a lower version.

Upvotes: 1

Views: 826

Answers (2)

Hannes Ovrén
Hannes Ovrén

Reputation: 21831

To expand on berak's answer:

The OpenCV C-API is a relic that should not be used unless you really have to. This has been the case for a long, long time. There are apparently still ways to access the old C API if you still need to. See the comment by berak on this post.

To capture video you should be using the cv::VideoCapture class in the C++ API. The link shows usage examples as well as the class reference.

If you have old code which uses the old C-API, your only options are to either remain on OpenCV 2.x, or rewrite to the C++ API.

Upvotes: 1

berak
berak

Reputation: 39796

the deprecated cv python api was removed from opencv3.0, CaptureFromCAM, etc are no more available.

please use opencv's cv2 api in python:

import numpy as np
import cv2

cv2.namedWindow("win")

camera = cv2.VideoCapture(0)
while camera.isOpened():
    ok, image=camera.read()
    if not ok:
        print 'no image read'
        break
    cv2.imshow("win", image)
    k = cv2.waitKey(1) & 0xff
    if k == 27 : break # esc pressed

Upvotes: 0

Related Questions