AVI to BMP to AVI

phipedro Messages postés 9 Date d'inscription mercredi 4 mai 2005 Statut Membre Dernière intervention 16 juillet 2005 - 10 mai 2005 à 09:36
phipedro Messages postés 9 Date d'inscription mercredi 4 mai 2005 Statut Membre Dernière intervention 16 juillet 2005 - 11 mai 2005 à 04:48
Voilà je suis étudiant en électronique(école d'ingé) et je suis en stage en Chine. Je dois créer une application qui permettrai de compter des personnes voir de les reconnaitre à l'aide d'une caméra. La carte est faite elle travaille avec un DSP de TI série 6000.
Il faut maintenant que j'écrive le code en C++ sous VC++ 6. Dans un premier temps, je voudrais partir d'une video AVI la transformer en image BMP puis transformer les images BMP en AVI mais pour l'instant, je n'arrive pas à retransformer les bmp pour avoir le même fichier qu'avant et lorsque je copie les BMP sur mon disque, elles sont décallés et elles ont un pb de couleur
aidez moi svp et soyez indulgent d'habitude je programme en C sous UNIX........

merci

1 réponse

phipedro Messages postés 9 Date d'inscription mercredi 4 mai 2005 Statut Membre Dernière intervention 16 juillet 2005
11 mai 2005 à 04:48
Voici le code que les 14 premières streams et je ne sais pas pourquoimais après ilne veut pas faire le "AVICreateStream":
int AVIExtraction(char* Name)
{
AVIFileInit();/*initialisation*/
PAVIFILE avi;

/*openning and test of the avi file*/
int r=AVIFileOpen(&avi, Name, OF_READ, NULL);
if(r!=AVIERR_OK)
{
if(avi!=NULL)
AVIFileRelease(avi);
puts("error in openning avi file");
return -1;
}


/*copy of the information*/
AVIFILEINFO info;
AVIFileInfo(avi, &info, sizeof(AVIFILEINFO));

/*getting and test of the stream for a video*/
PAVISTREAM avistream;
r=AVIFileGetStream(avi, &avistream, streamtypeVIDEO, 0);
if(r!=AVIERR_OK)
{
if(avistream!=NULL)
AVIStreamRelease(avistream);
AVIFileExit();
puts("error in getting the stream of the avi file");
return -1;
}


/*creation of bitmap pictures*/
int NFrames=AVIStreamLength(avistream);/*number of frame*/
int FirstFrame=AVIStreamStart(avistream);/*First Frame*/


BITMAPINFOHEADER BInfo;
ZeroMemory(&BInfo, sizeof(BITMAPINFOHEADER));/*restoring*/


BInfo.biBitCount = 12; /*24 bit per pixel*/
BInfo.biCompression = 0; /*BI_RGB;*/
BInfo.biHeight = info.dwHeight;
BInfo.biWidth = info.dwLength;
BInfo.biPlanes = 1;
BInfo.biSize = sizeof(BInfo);


/*prepare to decopress*/
PGETFRAME frame;
frame=AVIStreamGetFrameOpen(avistream, NULL);
if(frame==NULL)
{
puts("error in the preparation");
return -1;
}


PAVIFILE newavi;
/*openning and test of the avi file*/
r=AVIFileOpen(&newavi, "test.avi",OF_WRITE | OF_CREATE, NULL);
if(r!=0)
{
if(newavi!=NULL)
AVIFileRelease(newavi);
puts("error in openning avi file2");
return -1;
}


/*get the frames*/
int i,j=0;
for (i=FirstFrame; i<NFrames; i++)
{
j= i-FirstFrame;
puts("hello1");
int* pDIB =(int*) AVIStreamGetFrame(frame, j);
r=AVICreation(BInfo,pDIB, newavi);puts("hello2");
//BitmapCreation(pDIB, j);
if(r==FALSE)
{
puts("error in the avi movie creation loop");
printf("number of created stream : %d\n",j);
return -1;
}
}

AVIStreamGetFrameClose(frame);


/*close the stream */


if (avistream!=NULL)
AVIStreamRelease(avistream);


AVIFileExit();
puts(" the extraction is finshed");
return NFrames;
}





BOOL AVICreation(BITMAPINFOHEADER bih, int* pDIB,PAVIFILE newavi)
{


int r;
/*copy of the information*/
AVISTREAMINFO streaminfo;
ZeroMemory(&streaminfo, sizeof(AVISTREAMINFO));/*restoring*/


streaminfo.fccType = streamtypeVIDEO;
streaminfo.fccHandler =0;//mmioFOURCC('M','P','G','4');
streaminfo.dwScale = 1;
streaminfo.dwRate =30;
streaminfo.dwSuggestedBufferSize =0;
streaminfo.dwQuality =1000;
streaminfo.rcFrame.right =bih.biWidth;
streaminfo.rcFrame.bottom =bih.biHeight;


/*creation of the new stream*/
PAVISTREAM avistream;
r=AVIFileCreateStream(newavi,&avistream, &streaminfo);
if (r!=0)
{
puts("error in the creation of the new stream");
AVIFileRelease (newavi);
AVIFileExit ();
return FALSE;
}



/*format of the stream*/
AVIStreamSetFormat(avistream, 0, &bih, sizeof(bih));
if (r!=0)
{
puts("error in the setting of the stream format");
AVIStreamClose(avistream);
AVIFileRelease (newavi);
AVIFileExit ();
return FALSE;
}


/*stream writing */
AVIStreamWrite(avistream,0,30,pDIB,bih.biSizeImage,AVIIF_KEYFRAME,NULL,NULL);
puts("hello");
AVIFileRelease (newavi);

return TRUE;
}

MERCI de m'aider je me suis inspirer du WRITEAVI de MSDN et de différents code trouvés ici où sur d'autres sites.
0
Rejoignez-nous