Search code examples
opencvmatrixloopsjavacv

How to iterate through a cvMat matrix in JavaCV?


I have an IplImage that I converted in a Matrix, and now I want to iterate cell by cell.

CvMat mtx = new CvMat(iplUltima);
for (int i = 0; i < 100; i++) {
     //I need something like mtx[0][i] = someValue;
}

Solution

  • ¡¡I DID IT!! I share it:

    CvMat mtx = new CvMat(iplUltima);   
    
    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < 100; j++) {
             opencv_core.cvSet2D(mtx, i, j, CvScalar.ONE);
        }
    }
    iplUltima = new IplImage (mtx); 
    

    Where i = row and j = column