Converting `BufferedImage` to `Mat` in OpenCV

后端 未结 9 1900
北荒
北荒 2020-11-29 04:49

How can I convert a BufferedImage to a Mat in OpenCV?

I\'m using the JAVA wrapper for OpenCV(not JavaCV

9条回答
  •  误落风尘
    2020-11-29 05:12

    One simple way would be to create a new using

    Mat newMat = Mat(rows, cols, type);
    

    then get the pixel values from your BufferedImage and put into newMat using

    newMat.put(row, col, pixel);
    

提交回复
热议问题