Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visual c++ imread函数在windows上不适用于.PNG_Visual C++_Opencv3.0 - Fatal编程技术网

Visual c++ imread函数在windows上不适用于.PNG

Visual c++ imread函数在windows上不适用于.PNG,visual-c++,opencv3.0,Visual C++,Opencv3.0,我正在尝试使用 Mat_<float> depth_image_16_bit = imread(path_to_image, -1); Mat_uudepth_uimage_u16位=imread(路径到图像,-1); 但它无法加载。它显示断言错误。 它适用于Mat,但不适用于short或float如果在imread中使用参数-1,这相当于imread\u UNCHANGED,您将获得一个具有原始通道数的8位图像 因此,如果您的图像是: 单通道,您将获得一个Mat1b(又称M

我正在尝试使用

Mat_<float> depth_image_16_bit = imread(path_to_image, -1); 
Mat_uudepth_uimage_u16位=imread(路径到图像,-1);
但它无法加载。它显示断言错误。
它适用于
Mat
,但不适用于
short
float
如果在
imread
中使用参数
-1
,这相当于
imread\u UNCHANGED
,您将获得一个具有原始通道数的8位图像

因此,如果您的图像是:

  • 单通道,您将获得一个
    Mat1b
    (又称
    Mat
  • 3个频道,您将获得一个
    Mat3b
    (又称
    Mat\u Vec3b
  • 4个频道,您将获得一个
    Mat4b
    (又称
    Mat\u Vec4b
因此,您可以检查
Mat
的频道类型和数量,然后更改为更正
Mat\uu


或者,您可以以正确的深度加载它(如果您的图像每像素有2个字节,则这非常有用):

Mat img=imread(文件名,imread\u ANYDEPTH);
库特
Mat img = imread(filename, IMREAD_UNCHANGED);
cout << img.channels();
cout << img.depth() << endl;
Mat img = imread(filename, IMREAD_UNCHANGED);
img.convertTo(img, CV_32F); // now your image is of CV_32F type  
 Mat img = imread(filename, IMREAD_ANYDEPTH);
 cout << img.channels();
 cout << img.depth() << endl;