45 lines
922 B
Go
45 lines
922 B
Go
// +build ignore
|
|
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
|
|
"gocv.io/x/gocv"
|
|
)
|
|
|
|
func main() {
|
|
// GStreamer pipeline with explicit credentials
|
|
pipeline := "rtspsrc location=rtsp://192.168.2.183:554/stream2 user-id=tapohass user-pw=!!Helder06 latency=0 ! decodebin ! videoconvert ! appsink"
|
|
|
|
fmt.Println("Connecting to RTSP stream...")
|
|
stream, err := gocv.OpenVideoCapture(pipeline)
|
|
if err != nil {
|
|
fmt.Printf("Failed: %v\n", err)
|
|
return
|
|
}
|
|
defer stream.Close()
|
|
|
|
fmt.Println("Reading frame...")
|
|
frame := gocv.NewMat()
|
|
defer frame.Close()
|
|
|
|
// Skip a few frames to get a stable one
|
|
for i := 0; i < 5; i++ {
|
|
stream.Read(&frame)
|
|
time.Sleep(100 * time.Millisecond)
|
|
}
|
|
|
|
if frame.Empty() {
|
|
fmt.Println("Failed to read frame")
|
|
return
|
|
}
|
|
|
|
fmt.Printf("Frame size: %dx%d\n", frame.Cols(), frame.Rows())
|
|
|
|
// Save raw frame
|
|
gocv.IMWrite("test_raw_frame.png", frame)
|
|
fmt.Println("Saved to test_raw_frame.png")
|
|
}
|