Commit 2c9824b00f165debffaa8c696175009a70c600fc
1 parent
5a81b6db
Add support for streaming from webcams through OpenCV
When opening a video, check if the name can be converted to an integer, if so interpret it as an int, so it is opened as a camera by OpenCV
Showing
1 changed file
with
17 additions
and
1 deletions
openbr/plugins/stream.cpp
| ... | ... | @@ -270,7 +270,23 @@ public: |
| 270 | 270 | |
| 271 | 271 | next_idx = 0; |
| 272 | 272 | basis = input; |
| 273 | - video.open(input.file.name.toStdString()); | |
| 273 | + bool is_int = false; | |
| 274 | + int anInt = input.file.name.toInt(&is_int); | |
| 275 | + if (is_int) | |
| 276 | + { | |
| 277 | + bool rc = video.open(anInt); | |
| 278 | + | |
| 279 | + if (!rc) | |
| 280 | + { | |
| 281 | + qDebug("open failed!"); | |
| 282 | + } | |
| 283 | + if (!video.isOpened()) | |
| 284 | + { | |
| 285 | + qDebug("Video not open!"); | |
| 286 | + } | |
| 287 | + } | |
| 288 | + else video.open(input.file.name.toStdString()); | |
| 289 | + | |
| 274 | 290 | return video.isOpened(); |
| 275 | 291 | } |
| 276 | 292 | ... | ... |