是否可以使用cv :: VideoCapture加载32位帧

时间:2015-02-02 17:14:36

标签: c++ opencv

我正在尝试使用cv :: VideoCapture读取一堆CV_32FC1帧,但默认情况下它会像CV_8UC3一样加载它们。

我尝试使用VideoCapture::set()更改对象属性,但该方法一直返回0。

是否可以使用cv :: VideoCapture加载CV_32FC1个框架?我在文档中找不到答案,但我也找不到代码示例。

#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/core/core.hpp>
#include "opencv2/opencv.hpp"

int main(int argc , char** argv )
{
    VideoCapture capture;

    // return always 0:
    std::cout << "FORMAT" = " << capture.get( CV_CAP_PROP_FORMAT ) << std::endl;

    capture("./frames/frame_%02d.BMP";

    // return always 0:
    std::cout << "FORMAT" = " << capture.get( CV_CAP_PROP_FORMAT ) << std::endl;

    // status is always false
    bool status = capture.set( CV_CAP_PROP_FORMAT, CV_32FC1 );

    // still 0:
    std::cout << "FORMAT" = " << capture.get( CV_CAP_PROP_FORMAT ) << std::endl;

    if( !capture.isOpened() )  // isok?
        return -1;

    cv::Mat image;
    capture.read( image );

    // image is 8UC3

    return 0;
}

欢迎任何评论,谢谢。

1 个答案:

答案 0 :(得分:1)

正如berak在评论中所说:

"Is it possible to load CV_32FC1 frames using cv::VideoCapture?" - no. also, you can't store float images in a .bmp