doufang6268 2019-07-22 09:08
浏览 296

使用由gocv调用的opencv获得零帧

I am using opencv called from gocv to read a video via url which is a http request, and the http response body returns the video whose type is byte array. There is no problems in video file. I could get the video's fps and the totol frames number, but when I try to read the first frame or second frame, in return, I get a unexpected nil

but when I read the video from a given local file path, I can read the sencond frame as expected.

I am using c++ function to call this interface,however, the c++ function returns nil too. So could I just say that the videocaputure is not supported via a url?

url := "http://localhost:8080/video"

vc, err := gocv.OpenVideoCapture(url)

if nil != err {
    log.Fatal("open video capture failed: ", err)
}
defer vc.Close()

if !vc.IsOpened() {
    log.Fatal("vc is not open")
}
frames := 2
vc.Set(gocv.VideoCapturePosFrames, float64(frames))
frame := gocv.NewMat()
defer frame.Close()

// when I read video by srcPath, the vc.Read can read the frame
// when I read video by url, the vc.Read can't read the frame, and the error is the frame is nil
vc.Read(&frame)

if frame.Empty() {
    log.Fatal("frame is empty")
}

I expect the output is:read the frame success

The output is frame is nil, I can't get the frame

[mov,mp4,m4a,3gp,3g2,mj2 @ 0x19fd880] stream 1, offset 0xf50: partial file
...
...
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x26ee880] stream 1, offset 0xf50: partial file
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x26ee880] stream 1, offset 0xf50: partial file
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x26ee880] stream 1, offset 0xf50: partial file
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x26ee880] stream 1, offset 0xf50: partial file
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x26ee880] stream 1, offset 0xf50: partial file
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x26ee880] stream 1, offset 0xf50: partial file
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x26ee880] stream 1, offset 0xf50: partial file
2019/07/22 17:06:47 testMyVideo.go:37: frame is empty
exit status 1


  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 DIFY API Endpoint 问题。
    • ¥20 sub地址DHCP问题
    • ¥15 delta降尺度计算的一些细节,有偿
    • ¥15 Arduino红外遥控代码有问题
    • ¥15 数值计算离散正交多项式
    • ¥30 数值计算均差系数编程
    • ¥15 redis-full-check比较 两个集群的数据出错
    • ¥15 Matlab编程问题
    • ¥15 训练的多模态特征融合模型准确度很低怎么办
    • ¥15 kylin启动报错log4j类冲突