Ask Your Question

ssinfod's profile - activity

2016-07-26 09:16:03 -0600 commented question OpenCV 3.1 VideoWriter::write(const Mat&) does not return its status.

I tried it and there is no exception. Also errno is not set. I think the definition of the function should be changed...

I will write a message on the mailing list..

2016-07-22 21:09:46 -0600 asked a question OpenCV 3.1 VideoWriter::write(const Mat&) does not return its status.

Hello, I found it strange that the "VideoWriter::write(const Mat&)" function does not return its status (true/false).

I think that function should return an int to inform about the result of the call. (true (success) / false (fail))

The function declaration could be changed to: "virtual int write (const Mat &image)" instead of "virtual void write (const Mat &image)"

It would be easy to return the status because the source code inside write is using "cvWriteFrame(writer, &_img);" which returns an integer.

See definition and source here:

http://docs.opencv.org/master/dd/d9e/...

https://github.com/opencv/opencv/blob...

void VideoWriter::write(const Mat& image)
{
    if( iwriter )
        iwriter->write(image);
    else
    {
        IplImage _img = image;
        cvWriteFrame(writer, &_img);
    }
}

Otherwise, how can we know the status of the write call ?
(For example: it could fail because of the drive is full or there is a problem with the encoder or the storage device has been removed)

If my comment is relevant, where should I request that change ?

Thanks

2016-03-25 21:44:51 -0600 received badge  Enthusiast
2016-03-23 16:46:04 -0600 asked a question How to handle ffmpeg (libav/libavcodec) errors in C/C++ code.

Hello, I'm using OpenCV VideoWriter and the write functions in Linux (ubuntu) and also on the Raspberry Pi.

For some reasons, I sometimes encounters error of the encoding library. (which I suppose is ffmpeg (libav / libavcodec)

Here are some errors that I got: [mpeg4 @ 0x21d9580] get_buffer() failed (-12 (nil)) or [mpeg4 @ 0xfffb20] Error allocating a picture....

How can I handle (trap) these error in my C++ (or C) program ? (I see this message on the console output)

Does OpenCV knows that this error is happening ? Any idea what is causing these messages ? (it seems to occurs when I'm recording long video..)

Thanks ssinfod

2016-03-18 09:57:54 -0600 asked a question Which video library is OpenCV using under the hood on linux?

Hello, I'm writing a simple software to record (capture) a webcam image to a compressed video file. I'm mainly using "VideoCapture read(frame)" and "VideoWriter write(frame)" in my C++ software.

I'm on the Ubuntu 14.04 LTS operating system.

I would to know which library or API is OpenCV using under the hood. Is it ffmpeg or avconv or gstreamer or V4L2 or its own low level source code ? It seems to be changing depending of the OpenCV version I am using.

Can somebody give me a overview of the library used to decode and encode video device on linux ? What is the typical path of the video data coming from the webcam up to my program in user space ? What is the typical path of the video data coming from program up to the file system ?

Do you know any website or book which explains this video data flow ?

Right now, this is a bit confusing for me.

Thanks in advance for your input. ssinfod

2016-01-06 09:13:56 -0600 received badge  Editor (source)
2016-01-05 14:16:25 -0600 answered a question OpenCV problem

Does that mean that I must use OpenCV version 2.4.11 if I want to use C code ?

Is it right to say that OpenCV 3.1 doesn't support capture from a device in a C program ?

What about embedded devices ? I got the same error on a Raspberry Pi after updating to OpenCV 3.1 cvCapture* capture = cvCreateCameraCapture(0) does not work.

What is the definition of Deprecated ? Is it still permitted or not permitted to use C code with OpenCV 3.1 ?

2015-12-23 22:33:46 -0600 answered a question Display IplImage in webbrowsers

Here is a short example on how to convert IplImage to unsigned char and send it via a socket. (to simulate jpeg image sent from a web server). It is in C because I was not able to find any example for it...

CvCapture* camera;
IplImage* img_cam;
IplImage* img_web;
int params[2];
unsigned char* ptr;
unsigned char buf;
int i;
int buf_len;
char head[1024];

// Capture image and convert to jpg.
// I used cvCloneimage so I don't work on the original image.
img_cam = cvQueryFrame(camera);
img_web = cvCloneImage(img_cam);
params[0]= CV_IMWRITE_JPEG_QUALITY;
params[1]= 50; // Quality 0-100
CvMat* ei = cvEncodeImage(".jpg", img_web, params);
buf_len = ((ei->rows) * (ei->cols));
ptr = ei->data.ptr;
// Copy jpeg data from CvMat to unsigned char buffer.
for (i = 0 ; i < buf_len ; i++) {
    buf[i] = (*(ptr++));
}

...

// Send data via tcp socket.
SOCKET sock  = Accept(master); // See post above...
sprintf(head, "HTTP/1.1 200 OK\r\nServer: Built-in\r\nCache-Control: no-cache\r\nCache-Control: private\r\nContent-Type: image/jpeg\r\nContent-Length: %lu\r\nConnection: close\r\n\r\n", buf_len);
send(sock, head, strlen(head), MSG_NOSIGNAL);
send(sock, (uc*)(&buf[0]), buf_len, MSG_NOSIGNAL);
close(sock);
2015-12-23 22:33:45 -0600 commented answer Display IplImage in webbrowsers

I think the header should also contains "HTTP/1.1 200 OK"