Click here to Skip to main content
15,881,172 members
Articles / Desktop Programming / MFC

A Codecless Monochrome AVI Reader

Rate me:
Please Sign up or sign in to vote.
2.86/5 (4 votes)
14 May 20061 min read 45.7K   1.7K   29  
The way of reading AVI files without installing codec drivers.
/*****************************************************************************************************************
							Author : Fr�d�ric Ntawiniga
							Date   : May 14,2006
							Version: 1.1
							Avi monochrome file reader using Opencv
******************************************************************************************************************/

#ifndef _MONOCHROMEAVIREADER_H_
#define _MONOCHROMEAVIREADER_H_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <windows.h>
#include <vfw.h>

#include "huffyuv.h"

#include <cv.h>
#include <highgui.h>
#include <cvaux.h>

/*
#pragma comment(lib,"cxcore.lib")
#pragma comment(lib,"cv.lib")
#pragma comment(lib,"highgui.lib")
#pragma comment(lib,"vfw32.lib")
#pragma comment(lib,"huffyuv.lib")
*/

#define HFYU    mmioFOURCC('H','F','Y','U')	//compressed   data
#define hfyu    mmioFOURCC('h','f','y','u')	//compressed   data
#define Y800    mmioFOURCC('Y','8','0','0')	//uncompressed data
#define y800    mmioFOURCC('y','8','0','0')	//uncompressed data
#define DIB     mmioFOURCC('D','I','B',' ')	//uncompressed data
#define dib     mmioFOURCC('d','i','b',' ')	//uncompressed data

class CMonochromeAviReader  
{
public:
	CMonochromeAviReader();
	LONG GetNbFrames();
	int Open(const char* filename);
	IplImage* ReadFrame(unsigned int index);
	void Close();

	virtual ~CMonochromeAviReader();

private:

	
	IplImage*     m_pFrame;
	IplImage*     m_pFrameRGB;

	ICDECOMPRESS  m_icinfo;

	LONG		  m_streamLength;	// Length of the HFYU compressed data
	LONG          m_currentIndex;	// Frame Index in the AVI stream
	LONG          m_nbFrames;		// Number of frames in the AVI stream
	PAVIFILE	  m_pFile;			// Pointer to the AVI file
	PAVISTREAM	  m_pAviStream;		// Pointer to the AVI stream
	AVISTREAMINFO m_aviStreamInfo;	// AVI stream informations
	AVIFILEINFO   m_aviFileInfo;    // AVI file informations
	unsigned int  m_width;
	unsigned int  m_height;

	DWORD         m_fccHandler;
	int			  m_usedChannels;
	LONG		  m_fmtLength;
	LONG          m_frameStreamLength;

	CodecInst     m_codec;
};

#endif // _MONOCHROMEAVIREADER_H_

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Engineer
Canada Canada
Just programming

Comments and Discussions