gocv icon indicating copy to clipboard operation
gocv copied to clipboard

Why is my camera changing when i use VideoCaptureDevice

Open peachsoda0111 opened this issue 1 year ago • 0 comments

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 image

After executing the program. The camera id changes. Procedure

image

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 or env.cmd script before trying to go run or go build? no

peachsoda0111 avatar Dec 07 '22 03:12 peachsoda0111