How to stream video capture to web

I’ve the below code that read the cam and display it in GUI window, I want to push the same thing to my server at url localhost:8080/cam, how can I do this?

package main

import (

func main() {
	webcam, _ := gocv.VideoCaptureDevice(0)
	defer webcam.Close() // Close the cam once execution completed
	window := gocv.NewWindow("Hello")
	defer window.Close() // Close the GUI once execution completed, though it is done automatically
	img := gocv.NewMat()
	defer img.Close() // Close the img once execution completed

	for {
        // Want to do streaming here to localhost:8080/cam
		if window.WaitKey(1) == 27 { // 27 => Esc

That same project has a project and which demonstrate how to make an mjpeg stream.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.