2014-09-26 13:32:29 -0600 | asked a question | Android: Adding Values to a MatOfInt4 I am new to OpenCV, and am working with OpenCV4Android. It is frustrating because 99% of the examples online and all of the documentation are for C++ and they don't simply translate over in a lot of cases. I am working on a rectangle detection algorithm using the HoughLinesP algorithm. Right now, I run the algorithm and get a MatOfInt4 object (called lines) which has the detected line segments as an array of four doubles describing the endpoints of the line segment. I pass these to a method which extends these line segments to the borders of the screen. The problem is the algorithm finds more than 4 lines. It will usually find 6-10, where several are duplicates that essentially retrace a known line. So I have a method where I WANT to create a MatOfInt4 object of JUST the unique lines (called uniqueLines). So I scan through each column in lines and compare it to all of the entries in uniqueLines. If the endpoints are identical (within a threshold), it should reject the line, but if the line being inspected doesn't match any other, it is added to uniqueLines. When the method finishes, I return the uniqueLines object. The problem is that when I try to put val into the uniqueLines object, it doesn't actually get placed there, so when on the next iteration I call uniqueLines.get(0, j) and try to reference the data that was supposed to have been placed in there, I get a null pointer exception. I also tried converting val into a Mat object and using the push_back method, but it only adds the first unique line and subsequent calls to push_back do absolutely nothing. Any assistance would be greatly appreciated. |