java - Unable to clone ArrayList<MatOfPoint> elements -


i using following code clone array:

aproximatedcontours = clonelist(contours); 

the body of method:

public static arraylist<matofpoint> clonelist(arraylist<matofpoint> contours) {     arraylist<matofpoint> clone = new arraylist<matofpoint>(contours.size());     for(matofpoint item: contours)          clone.add((matofpoint) item.clone()); // line 479     return clone; } 

however, though both contours , clone type of arraylist, , elements type of matofpoint, following error:

08-16 16:34:16.015: w/system.err(21747): java.lang.classcastexception: org.opencv.core.mat cannot cast org.opencv.core.matofpoint 08-16 16:34:16.020: w/system.err(21747):    @ com.example.objecttracker.objecttracker.clonelist(objecttracker.java:469) 08-16 16:34:16.020: w/system.err(21747):    @ com.example.objecttracker.objecttracker.oncameraframe(objecttracker.java:446) 08-16 16:34:16.020: w/system.err(21747):    @ org.opencv.android.camerabridgeviewbase.deliveranddrawframe(camerabridgeviewbase.java:387) 08-16 16:34:16.020: w/system.err(21747):    @ org.opencv.android.javacameraview$cameraworker.run(javacameraview.java:321) 08-16 16:34:16.025: w/system.err(21747):    @ java.lang.thread.run(thread.java:856) 

does have idea happeining here?

this appears api bug in matofpoint: inherits clone method mat, when call it, you're getting plain mat returned (and presumably superclass's fields copied). overall semantics matofpoint don't appear cleanly defined, , there's no mechanism copying one.

edit: if native object handle contains of necessary data, might able use new matofpoint(mat m) copy constructor.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -