gocv
gocv copied to clipboard
Why is my camera changing when i use VideoCaptureDevice
I want to get the camera content via VideoCaptureDevice and when I pass in my virtual camera ID, it always turns on the virtual camera on the first run and the computer camera on the second run.
Description
my code:
func main() { webcam, _ := gocv.VideoCaptureDevice(1) // my virtual camera id is 1 defer webcam.Close() window := gocv.NewWindow("test") defer window.Close() img := gocv.NewMat() defer img.Close() timeUnix:=time.Now().Unix() + 3 for { if time.Now().Unix() > timeUnix { break } webcam.Read(&img) window.IMShow(img) window.WaitKey(1) } }
Before executing the programmy camera id
After executing the program. The camera id changes. Procedure
Your Environment
- Operating System and version: MacOS Ventura 13.0.1 macbookpro M1
- OpenCV version used: 4.5.3
- How did you install OpenCV? yes
- GoCV version used:0.31.0
- Go version: go1.17.2 darwin/arm64
- Did you run the
env.sh
orenv.cmd
script before trying togo run
orgo build
? no