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

Is it possible to load 32 bits frames using cv::VideoCapture

本文关键字:加载 位帧 VideoCapture 是否 cv 可以使      更新时间:2023-10-16

我正在尝试使用 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;
}

欢迎任何评论,提前感谢。

正如 berak 在评论中的 sait :

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