18
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

OpenCV 2系からOpenCV 3系に乗り換えた時に引っかかる"CV_CAP_PROP_XXX(propId)"の対応表

Last updated at Posted at 2017-05-22

#概要
OpenCV2で

cap = cv2.VideoCapture('movie.avi')
frames = int(cap.get(cv2.cv.CV_CAP_PROP_FRAME_COUNT))

といった感じで処理していた部分をOpenCV3に切り替えたらエラーを吐かれるので、

cap = cv2.VideoCapture('movie.avi')
frames = int(cap.get(7))

に切り替えたら解決する。

要は現在のOpenCV3(3.2)ではVideocaptureクラスまわりの関数の説明で、プロップID(propId)とされている部分(CV_CAP_PROP_XXX)が各々対応した0~18の数字に切り替えられたという話。

#対応表

propId name propId No. Description
CV_CAP_PROP_POS_MSEC 0 Current position of the video file in milliseconds.
CV_CAP_PROP_POS_FRAMES 1 0-based index of the frame to be decoded/captured next.
CV_CAP_PROP_POS_AVI_RATIO 2 Relative position of the video file: 0 - start of the film, 1 - end of the film.
CV_CAP_PROP_FRAME_WIDTH 3 Width of the frames in the video stream.
CV_CAP_PROP_FRAME_HEIGHT 4 Height of the frames in the video stream.
CV_CAP_PROP_FPS 5 Frame rate.
CV_CAP_PROP_FOURCC 6 4-character code of codec.
CV_CAP_PROP_FRAME_COUNT 7 Number of frames in the video file.
CV_CAP_PROP_FORMAT 8 Format of the Mat objects returned by retrieve().
CV_CAP_PROP_MODE 9 Backend-specific value indicating the current capture mode.
CV_CAP_PROP_BRIGHTNESS 10 Brightness of the image (only for cameras).
CV_CAP_PROP_CONTRAST 11 Contrast of the image (only for cameras).
CV_CAP_PROP_SATURATION 12 Saturation of the image (only for cameras).
CV_CAP_PROP_HUE 13 Hue of the image (only for cameras).
CV_CAP_PROP_GAIN 14 Gain of the image (only for cameras).
CV_CAP_PROP_EXPOSURE 15 Exposure (only for cameras).
CV_CAP_PROP_CONVERT_RGB 16 Boolean flags indicating whether images should be converted to RGB.
CV_CAP_PROP_WHITE_BALANCE 17 Currently unsupported.
CV_CAP_PROP_RECTIFICATION 18 Rectification flag for stereo cameras (note: only supported by DC1394 v 2.x backend currently).

参考

追記、OpenCVがマイナーチェンジしているので、若干古い情報となっています。今は使えますが気をつけてください。

18
16
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?