Skip to content

Commit ab1a9e2

Browse files
authored
Merge pull request openalpr#398 from Max13/read_pipe
Added read from piped standard input support
2 parents cd2aab0 + 99f9984 commit ab1a9e2

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/main.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,27 @@ int main( int argc, const char** argv )
145145
{
146146
std::string filename = filenames[i];
147147

148-
if (filename == "stdin")
148+
if (filename == "-")
149+
{
150+
std::vector<uchar> data;
151+
int c;
152+
153+
while ((c = fgetc(stdin)) != EOF)
154+
{
155+
data.push_back((uchar) c);
156+
}
157+
158+
frame = cv::imdecode(cv::Mat(data), 1);
159+
if (!frame.empty())
160+
{
161+
detectandshow(&alpr, frame, "", outputJson);
162+
}
163+
else
164+
{
165+
std::cerr << "Image invalid: " << filename << std::endl;
166+
}
167+
}
168+
else if (filename == "stdin")
149169
{
150170
std::string filename;
151171
while (std::getline(std::cin, filename))

0 commit comments

Comments
 (0)