Beispiel #1
0
CvVideoWriter* cvCreateVideoWriter_GStreamer( const char* filename )
{
	CvVideoWriter_GStreamer *writer;

	unsigned offset = 0;
	char *name = icvExtractPattern(filename, &offset);
	if(!name)
		return 0;

	char str[100];
	char *x = str;
	int size = 100;
	while(snprintf(x, size, name, 0) == size - 1) {
		size *= 2;
		if(x == str)
			x = (char *)malloc(size);
		else
			x = (char *)realloc(x, size);
	}
	if(!cvHaveImageWriter(x)) {
		if(x != str)
			free(x);
		return 0;
	}
	if(x != str)
		free(x);

	writer = (CvVideoWriter_GStreamer *)cvAlloc(sizeof(CvCapture_GStreamer));
	memset(writer, 0, sizeof(CvVideoWriter_GStreamer));
	writer->filename = strdup(name);
	writer->currentframe = offset;

	return (CvVideoWriter *)writer;
}
Beispiel #2
0
bool CvCapture_Images::open(const char * _filename)
{
    unsigned offset = 0;
    close();

    filename = icvExtractPattern(_filename, &offset);
    if(!filename)
        return false;

    // determine the length of the sequence
    length = 0;
    char str[_MAX_PATH];
    for(;;)
    {
        sprintf(str, filename, offset + length);
        struct stat s;
        if(stat(str, &s))
        {
            if(length == 0 && offset == 0) // allow starting with 0 or 1
            {
                offset++;
                continue;
            }
        }

        if(!cvHaveImageReader(str))
            break;

        length++;
    }

    if(length == 0)
    {
        close();
        return false;
    }

    firstframe = offset;

    // grab frame to enable properties retrieval
    bool grabRes = grabFrame();
    grabbedInOpen = true;
    currentframe = 0;

    return grabRes;
}
Beispiel #3
0
bool CvVideoWriter_Images::open(const char* _filename) {
    unsigned offset = 0;

    close();

    filename = icvExtractPattern(_filename, &offset);
    if (!filename) {
        return false;
    }

    char str[_MAX_PATH];
    sprintf(str, filename, 0);
    if (!cvHaveImageWriter(str)) {
        close();
        return false;
    }

    currentframe = offset;
    return true;
}
Beispiel #4
0
bool CvCapture_Images::open(const char* _filename) {
    unsigned offset = 0;
    close();

    filename = icvExtractPattern(_filename, &offset);
    if (!filename) {
        return false;
    }

    // determine the length of the sequence
    length = 0;
    char str[_MAX_PATH];
    for (;;) {
        sprintf(str, filename, offset + length);
        struct stat s;
        if (stat(str, &s)) {
            if (length == 0 && offset == 0) { // allow starting with 0 or 1
                offset++;
                continue;
            }
        }

        if (!cvHaveImageReader(str)) {
            break;
        }

        length++;
    }

    if (length == 0) {
        close();
        return false;
    }

    firstframe = offset;
    return true;
}