[color=darkblue]Estou usando o OpenCV, precisava de um exemplo de leitura de .AVI ou qualquer outro formato de vídeo.
Eu consegui, mas estou tendo problemas, se alguém puder ajudar desde já agradeço ![/color]
[color=darkblue]Estou usando o OpenCV, precisava de um exemplo de leitura de .AVI ou qualquer outro formato de vídeo.
Eu consegui, mas estou tendo problemas, se alguém puder ajudar desde já agradeço ![/color]
[color=darkblue]Consegui solucionar os problemas que encontrei, agora estou tendo novos problemas, alguns também “solucionei”, mas tenho problemas de como fazer ele capturar arquivos um pouco maiores, exemplo a partir de uns 40 mb, se alguém puder ajudar desde já agradeço, segue um código funcional que encontrei [/color]
// This is the main project file for VC++ application project
// generated using an Application Wizard.
#include "stdafx.h"
#include <stdio.h>
#include "cv.h"
#include "highgui.h"
#include "_highgui.h"
#using <mscorlib.dll>
using namespace System;
IplImage *frame = 0;
IplImage *frame_copy = 0;
IplImage *temp = 0;
IplImage *temp_h = 0;
IplImage *temp_s = 0;
IplImage *temp_v = 0;
void main()
{
// open a window named "example".
cvNamedWindow("example");
// create capture from file.
CvCapture* cap = cvCaptureFromAVI("c:\\Age2_X1.avi");
if (cap == NULL)
{
printf("Unable to open video file.\n");
return;
}
// get capture parameters.
int width = (int) cvGetCaptureProperty(cap, CV_CAP_PROP_FRAME_WIDTH);
int height = (int) cvGetCaptureProperty(cap, CV_CAP_PROP_FRAME_HEIGHT);
int fps = (int) cvGetCaptureProperty(cap, CV_CAP_PROP_FPS);
// create video writer for the output.
// CvVideoWriter* writer = cvCreateVideoWriter("c:\\myoutput.avi", 0, fps, cvSize(width, height));
IplImage* frame;
while((frame = cvQueryFrame(cap)))
{
// clone the image, so it could be manipulated.
IplImage* clone = cvCloneImage(frame);
// iterate over all the pixels in the frame.
for (int row = 0; row < clone->height; ++row)
{
for (int col = 0; col < clone->width * clone->nChannels; col = col + clone->nChannels)
{
// iterate over all the color channels.
for (int ch = 0; ch < clone->nChannels; ++ch)
{
// get the pixel value.
BYTE pixel = CV_IMAGE_ELEM(clone, BYTE, row, col + ch);
// invert it.
CV_IMAGE_ELEM(clone, BYTE, row, col + ch) = 255 - pixel;
}
}
}
// display image in window and write to output file.
cvShowImage("example", clone);
// cvWriteFrame(writer, clone);
// release the clone.
cvReleaseImage(&clone);
// hold on for 100 / fps time.
int key = cvWaitKey(1000 / fps);
if (key == 27) break;
}
// release the capture and video writer.
// cvReleaseCapture(&cap);
printf("Done\n");
}