Skip to content

Commit

Permalink
Add isColor to VideoWriterFile
Browse files Browse the repository at this point in the history
  • Loading branch information
denismakogon committed May 16, 2018
1 parent c45da33 commit 5f18673
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions videoio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions videoio.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 "+
Expand All @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion videoio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions videoio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
}
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 5f18673

Please sign in to comment.