Read h264 frame into a byte slice

This commit is contained in:
Russell Stanley 2022-01-10 14:17:52 +10:30 committed by Saxon Nelson-Milton
parent 7da2097cf9
commit 3614d5c2cc
2 changed files with 24 additions and 8 deletions

Binary file not shown.

View File

@ -1,18 +1,34 @@
package main package main
import ( import (
"fmt" "io/ioutil"
"testing" "testing"
"gocv.io/x/gocv"
) )
func TestMain(m *testing.M) { func TestMain(t *testing.T) {
//ts := new(turbidityProbe)
const (
rows = 2464
cols = 3280
)
ts := new(turbidityProbe) // Read frame
frame, err := ioutil.ReadFile("AusOcean_logo_1080p.h264")
if err != nil {
t.Fatal(err)
}
frame := make([]byte, 10) // Decode
//mat, err := gocv.NewMatFromBytes(rows, cols, gocv.MatTypeCV8UC3, frame)
mat, err := gocv.IMDecode(frame, gocv.IMReadUnchanged)
if err != nil {
t.Fatal(err)
}
if mat.Empty() {
t.Fatal("Empty gocv.Mat")
}
size, err := ts.Write(frame) gocv.IMWrite("logo.jpg", mat)
fmt.Println(size)
fmt.Println(err)
} }