Android Question OpenCV fillpoly method java.utils.list

gezueb

Active Member
Licensed User
Hi, i try to fill a contour with a list of points with some code like this:
B4X:
   Dim contours as List
    contours.Initialize 'reset and find the contours again
    mImgProc.findContours(ContourMat, contours, hierarchy, mImgProc.RETR_External,mImgProc.CHAIN_APPROX_SIMPLE, offset)
    
    For i=0 To contours.Size-1
        Dim mat As OCVMatOfPoint = contours.Get(i)
        a = mImgProc.contourArea(contours.Get(i),False) 'true means closed shape, which is not always the case
        If a>5 Then 'there must be an aera of some size, otherwise it is just a line
            Dim pnt() As OCVPoint = mat.toArray
            Dim pntlist As List
            pntlist.Initialize2(mat.toList)
            mImgProc.fillPoly1(ContourMat,[B]pntlist[/B] ,grayscalarwhite)
            Log("i: "&i&", area: " & a &" number of points: "&pnt.Length )    'the area is only the white pixels, not the encompassing area
        End If
    Next
However I have not found out how the second parameter of the call mImgProc.fillPoly1, the "pts of java.utils.list" must be set up. Whatever I write there throw a run tim eexception that parameters cannot be cast to whatever. The find contours method works okay.
Thanks for help
 

DonManfred

Expert
Licensed User
mat.toList instead of pntlist does not work?
 
Upvote 0

gezueb

Active Member
Licensed User
You mean like this?
B4X:
            Dim pntlist As List = mat.tolist
            mImgProc.fillPoly1(ContourMat,pntlist ,grayscalarwhite)
That throws an exception:
java.lang.ClassCastException: org.opencv.core.Point cannot be cast to org.opencv.core.MatOfPoint
 
Upvote 0
Top