How to I simply initalize an opencv MAT object with values? (answered)

edited July 2015 in Library Questions
OpenCV opencv;
Mat A = new Mat(4,4,CvType.CV_64F);

Then how to access A to set/retrieve specific values from certain indexes?

Thanks

Tagged:

Answers

  • edited July 2015

    To insert data it would be something like this:

    import gab.opencv.*;
    import org.opencv.core.Mat;
    import org.opencv.core.CvType;
    
    int row = 0, col = 0;
    int data[] = {  0, -1, 0, -1, 5, -1, 0, -1, 0 };
    Mat M = new Mat(3, 3, CvType.CV_32S );
    M.put( row, col, data );
    

    As explained here.

    Use this to retrieve information from specific index:

    M.get( row , col );

    from this trick referecence

Sign In or Register to comment.