mirror of https://bitbucket.org/ausocean/av.git
Read h264 frame into a byte slice
This commit is contained in:
parent
7da2097cf9
commit
3614d5c2cc
Binary file not shown.
|
@ -1,18 +1,34 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"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)
|
||||
|
||||
frame := make([]byte, 10)
|
||||
|
||||
size, err := ts.Write(frame)
|
||||
|
||||
fmt.Println(size)
|
||||
fmt.Println(err)
|
||||
// Read frame
|
||||
frame, err := ioutil.ReadFile("AusOcean_logo_1080p.h264")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// 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")
|
||||
}
|
||||
|
||||
gocv.IMWrite("logo.jpg", mat)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue