OpenCV Constants.CaptureProperty

前端 未结 3 1977
日久生厌
日久生厌 2020-12-11 11:52

Hi I use OpenCV Java and have some problem.

I open video file and try get property like FPS. And others:

  • CV_CAP_PROP_POS_MSEC
  • CV_CAP_PROP_FRA
相关标签:
3条回答
  • 2020-12-11 12:32

    There is a bug report about this issue.

    Until it is fixed, I suggest that you find these constants in the C++ source code, and define them yourself.

    Edit:

    I was just curious myself. You find them in the file modules/highgui/include/opencv2/highgui.hpp They are:

       CAP_PROP_POS_MSEC       =0,
       CAP_PROP_POS_FRAMES     =1,
       CAP_PROP_POS_AVI_RATIO  =2,
       CAP_PROP_FRAME_WIDTH    =3,
       CAP_PROP_FRAME_HEIGHT   =4,
       CAP_PROP_FPS            =5,
       CAP_PROP_FOURCC         =6,
       CAP_PROP_FRAME_COUNT    =7,
       CAP_PROP_FORMAT         =8,
       CAP_PROP_MODE           =9,
       CAP_PROP_BRIGHTNESS    =10,
       CAP_PROP_CONTRAST      =11,
       CAP_PROP_SATURATION    =12,
       CAP_PROP_HUE           =13,
       CAP_PROP_GAIN          =14,
       CAP_PROP_EXPOSURE      =15,
       CAP_PROP_CONVERT_RGB   =16,
       CAP_PROP_WHITE_BALANCE_BLUE_U =17,
       CAP_PROP_RECTIFICATION =18,
       CAP_PROP_MONOCROME     =19,
       CAP_PROP_SHARPNESS     =20,
       CAP_PROP_AUTO_EXPOSURE =21, // DC1394: exposure control done by camera, user can adjust refernce level using this feature
       CAP_PROP_GAMMA         =22,
       CAP_PROP_TEMPERATURE   =23,
       CAP_PROP_TRIGGER       =24,
       CAP_PROP_TRIGGER_DELAY =25,
       CAP_PROP_WHITE_BALANCE_RED_V =26,
       CAP_PROP_ZOOM          =27,
       CAP_PROP_FOCUS         =28,
       CAP_PROP_GUID          =29,
       CAP_PROP_ISO_SPEED     =30,
       CAP_PROP_BACKLIGHT     =32,
       CAP_PROP_PAN           =33,
       CAP_PROP_TILT          =34,
       CAP_PROP_ROLL          =35,
       CAP_PROP_IRIS          =36,
       CAP_PROP_SETTINGS      =37
    
    0 讨论(0)
  • 2020-12-11 12:38

    It seems the bug is solved. Now you should be able to use it as:

    VideoCapture vC = new VideoCapture(...);
    nbFrames = vC.get(Videoio.CAP_PROP_FRAME_COUNT);
    
    0 讨论(0)
  • use class import org.opencv.videoio.Videoio;

    vc.open(FD.class.getResource("1.avi").getPath());
    double totalFrameNumber = vc.get(Videoio.CAP_PROP_FRAME_COUNT);  
    System.out.println("\n"+totalFrameNumber);
    
    0 讨论(0)
提交回复
热议问题