OpenCV: reading image from std :: in?

Can I use the OpenCV imread function to read from std::in ?

 Mat imread( const string& filename, int flags=1 ); 

The function accepts only the file name, but is there any β€œmagic” value for stdin?

+2
source share
3 answers

OpenCV provides imdecode functions that work with buffers instead of a file name. First you will need to read stdin into the buffer.

http://opencv.willowgarage.com/documentation/cpp/reading_and_writing_images_and_video.html

+2
source

If you want to crack very quickly, here is what works on Linux:

 #include <unistd.h> /* snip */ std::stringstream ss; ss << "/proc/" << getpid() << "/fd/0"; cv::Mat m = cv::imread(ss.str()); 
+1
source

No,

But if you really want to, you can pass stdin to the named pipe (mkfifo) and read it.

0
source

Source: https://habr.com/ru/post/1469289/


All Articles