2

動作し、適切なプロパティを返す C コードがあります。

int main(int argc, char** argv) {

    CvCapture *capture = NULL; 
    const char* filename = "foo.mov";

    capture = cvCreateFileCapture(filename);
    int w = (int)cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH);
    int h = (int)cvGetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT);

    std::cout << "Width:  " << w << std::endl;
    std::cout << "Height: " << h << std::endl;

しかし、同等の Python はすべてに対して 0 を返します:

import cv2

capture = cv2.VideoCapture('foo.mov')

print capture.get(cv2.cv.CV_CAP_PROP_FRAME_WIDTH)

これは戻ります0.0

何か案は?

4

1 に答える 1

0
  1. Pythoncで開いている cv バージョンを確認します。

    from cv2 importバージョン バージョン

    そしてCV_VERSIONマクロを使用。

  2. 何のための出力か capture.get(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT)

  3. python と foo.mov は同じディレクトリにありますか?

于 2013-03-27T22:10:47.967 に答える