From 5f18673277015c830a91b1dc2b83a48619472846 Mon Sep 17 00:00:00 2001 From: Denis Makogon Date: Thu, 17 May 2018 01:33:56 +0300 Subject: [PATCH] Add isColor to VideoWriterFile Closes: #196 --- videoio.cpp | 4 ++-- videoio.go | 4 ++-- videoio.h | 2 +- videoio_test.go | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/videoio.cpp b/videoio.cpp index ed513eff..87c030bc 100644 --- a/videoio.cpp +++ b/videoio.cpp @@ -49,9 +49,9 @@ void VideoWriter_Close(VideoWriter vw) { } void VideoWriter_Open(VideoWriter vw, const char* name, const char* codec, double fps, int width, - int height) { + int height, bool isColor = true) { int codecCode = cv::VideoWriter::fourcc(codec[0], codec[1], codec[2], codec[3]); - vw->open(name, codecCode, fps, cv::Size(width, height), true); + vw->open(name, codecCode, fps, cv::Size(width, height), isColor); } int VideoWriter_IsOpened(VideoWriter vw) { diff --git a/videoio.go b/videoio.go index 87978c80..cd661053 100644 --- a/videoio.go +++ b/videoio.go @@ -241,7 +241,7 @@ type VideoWriter struct { // For further details, please see: // http://docs.opencv.org/master/dd/d9e/classcv_1_1VideoWriter.html#a0901c353cd5ea05bba455317dab81130 // -func VideoWriterFile(name string, codec string, fps float64, width int, height int) (vw *VideoWriter, err error) { +func VideoWriterFile(name string, codec string, fps float64, width int, height int, isColor bool) (vw *VideoWriter, err error) { if fps == 0 || width == 0 || height == 0 { return nil, fmt.Errorf("one of the numerical parameters "+ @@ -259,7 +259,7 @@ func VideoWriterFile(name string, codec string, fps float64, width int, height i cCodec := C.CString(codec) defer C.free(unsafe.Pointer(cCodec)) - C.VideoWriter_Open(vw.p, cName, cCodec, C.double(fps), C.int(width), C.int(height)) + C.VideoWriter_Open(vw.p, cName, cCodec, C.double(fps), C.int(width), C.int(height), C.bool(isColor)) return } diff --git a/videoio.h b/videoio.h index 6b90adc2..1c22972a 100644 --- a/videoio.h +++ b/videoio.h @@ -31,7 +31,7 @@ void VideoCapture_Grab(VideoCapture v, int skip); VideoWriter VideoWriter_New(); void VideoWriter_Close(VideoWriter vw); void VideoWriter_Open(VideoWriter vw, const char* name, const char* codec, double fps, int width, - int height); + int height, bool isColor = true); int VideoWriter_IsOpened(VideoWriter vw); void VideoWriter_Write(VideoWriter vw, Mat img); diff --git a/videoio_test.go b/videoio_test.go index 6c609d67..2ce408a8 100644 --- a/videoio_test.go +++ b/videoio_test.go @@ -9,7 +9,7 @@ import ( func TestVideoCaptureEmptyNumericalParameters(t *testing.T) { _, err := VideoWriterFile( - "images/small.mp4", "MJPEG", 0, 0, 0) + "images/small.mp4", "MJPEG", 0, 0, 0, true) if err == nil { t.Error("Must fail due to an empty numerical parameters.") } @@ -67,7 +67,7 @@ func TestVideoWriterFile(t *testing.T) { } defer img.Close() - vw, _ := VideoWriterFile(tmpfn, "MJPG", 25, img.Cols(), img.Rows()) + vw, _ := VideoWriterFile(tmpfn, "MJPG", 25, img.Cols(), img.Rows(), true) defer vw.Close() if !vw.IsOpened() {