forked from hybridgroup/gocv
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Can capture video Mat buffers and display them in a Window
Signed-off-by: deadprogram <[email protected]>
- Loading branch information
1 parent
6599469
commit 768da9b
Showing
8 changed files
with
53 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
opencv3 ".." | ||
) | ||
|
||
func main() { | ||
deviceID := 0 | ||
webcam := opencv3.NewVideoCapture() | ||
defer webcam.Delete() | ||
|
||
if ok := webcam.OpenDevice(int(deviceID)); !ok { | ||
fmt.Printf("error opening device: %v\n", deviceID) | ||
return | ||
} | ||
|
||
window := opencv3.NewWindow("Capture") | ||
|
||
// streaming, capture from webcam | ||
img := opencv3.NewMat() | ||
defer img.Delete() | ||
fmt.Printf("start reading camera device: %v\n", deviceID) | ||
for { | ||
if ok := webcam.Read(img); !ok { | ||
fmt.Printf("cannot read device %d\n", deviceID) | ||
return | ||
} | ||
if img.Empty() { | ||
continue | ||
} | ||
|
||
window.IMShow(img) | ||
opencv3.WaitKey(1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters