1

I am using the probabilistic hough transform of OpenCV via OpenCV's Java wrapper. These are stored in a Mat though and while the approach of an already existing answer works, I discovered that there is a Converters class specifically for converting Mats into Collections back and forth.

However, all potentially suitable converters expect the Mat in question to only have 1 column and multiple rows. The Mat „returned” by HoughLinesP however has the resulting points stored in a single row, one line per column storing a double[] per „pixel” in the Mat with 4 components. This results in this exception:

Caused by: java.lang.IllegalArgumentException: CvType.CV_32SC2 != m.type() ||  m.cols()!=1
    Mat [ 1*4*CV_32SC4, isCont=true, isSubmat=false, nativeObj=0x7fe913e98890, dataAddr=0x7fe913ca7e50 ]
    at org.opencv.utils.Converters.Mat_to_vector_Mat(Converters.java:258)
    at org.opencv.utils.Converters.Mat_to_vector_vector_Point2f(Converters.java:516)

Are the OpenCV Converters meant for what I am trying to use them for? Is there a better way to do that or is my only option to tediously read every pixel in the resulting Mat myself?

Community
  • 1
  • 1
phdoerfler
  • 452
  • 6
  • 18

0 Answers0