【发布时间】:2014-10-07 17:35:57
【问题描述】:
我正在尝试使用以下代码从标准输入读取 jpg 图像:
int c,count=0;
vector<uchar> buffer; //buffer for coding
/* for stdin, we need to read in the entire stream until EOF */
while ((c = fgetc(stdin)) != EOF) {
buffer.push_back(c);
count++;
}
cout << "Bytes: " << count << endl;
Mat im = imdecode(Mat(buffer),CV_LOAD_IMAGE_COLOR);
cout << "Decoded\n";
namedWindow("image", CV_WINDOW_AUTOSIZE);
imshow("image",im);
cv::waitKey(0);
我在 cmd 中运行这个:
OpenCVTest < thumb.jpg
这是我得到的:
Bytes: 335
Decoded
OpenCV Error: Bad flag (parameter or structure field) (Unrecognized or unsupported array type) in unknown function, file ..\..\..\src\opencv\modules\core\src\array.cpp, line 2482
这个错误似乎是合理的,因为图像大约 7 KB,但根据计数器只读取了 335 个字节。
我做错了什么?
我的最终目标是逐帧从标准输入读取视频。这可能吗?
非常感谢!
【问题讨论】:
标签: opencv