Search code examples
macosgowebcam

what is a correct path for macbook webcam


I am trying to get a stream from MacBook High Sierra webcam, mac does not have /dev/video0
is there any way to access MacOS webcam ?
I am programming in golang and I am using golang.org/x/sys/unix


Solution

  • You can use OpenCV bindings and get frame from camera.

    Have a look at godoc for go-opencv

    A short example:

    index := 0 // example
    camera := opencv.NewCameraCapture(index)
    
    if camera.GrabFrame() {
        frame := camera.RetrieveFrame(1)
        img := frame.ToImage()
    }