OpenCV: Convertion IplImage to Mat
Alors voilà, mon problème est tout simple:
Je souhaite convertir une séquence d'images au format IplImage vers le format Mat.
Pour convertir une seule image, pas de problème, cela se lance correctement:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
IplImage * img2[579];
IplImage * img3[579];
// charge the list of images to studye
for (int k=0; k<579; k++)
{
stringstream ss;
if(k<10)
{
ss << "lc-0000" << k+1 << ".png";
img2[k] = cvLoadImage(ss.str().c_str());
}
else if((k>9)&&(k<100))
{
ss << "lc-000" << k+1 << ".png";
img2[k] = cvLoadImage(ss.str().c_str());
}
else
{
ss << "lc-00" << k+1 << ".png";
img2[k] = cvLoadImage(ss.str().c_str());
}
}
Mat imgMat3(img2[0]);
Mat imgMat212(img2[12]);
Mat imgMat2(img2[2]); // cette ligne marche |
Par contre, si je passe dans une boucle, ça plante lors du lancement:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
IplImage * img2[579];
IplImage * img3[579];
// charge the list of images to studye
for (int k=0; k<579; k++)
{
stringstream ss;
if(k<10)
{
ss << "lc-0000" << k+1 << ".png";
img2[k] = cvLoadImage(ss.str().c_str());
}
else if((k>9)&&(k<100))
{
ss << "lc-000" << k+1 << ".png";
img2[k] = cvLoadImage(ss.str().c_str());
}
else
{
ss << "lc-00" << k+1 << ".png";
img2[k] = cvLoadImage(ss.str().c_str());
}
}
Mat imgMat3(img2[0]);
Mat imgMat212(img2[12]);
// Cette boucle ne marche pas. En fait, ce que je veux faire, c'est soustraire chaque img2[h] avec la img2[12], la douzième et la mettre dans img3[h]. Le problème c'est qu'il faut convertir en Matrice Mat.
for(int h=0; h<579; h++)
{
Mat imgMat2(img2[h]); // c'est cette ligne qui plante je crois
absdiff(imgMat2, imgMat212, imgMat3);
img3[h] = &(IplImage(imgMat3));
} |
img2[] et img3[] étant des tableaux de IplImages.
Comment faire? :calim2:
Mayday :cry: viens du français "venez m'aider !!" les anglais l'ont alors déformé en "mayday" (pour la petite histoire )