i want calculate homography of images using opencv in java, throws exception: opencv error: bad argument (the input arrays should 2d or 3d point sets) in cv::findhomography
my code (because code long posted part of code):
.... list<point> obj = new arraylist<>(); list<point> scene = new arraylist<>(); keypoint[] _keypoints_object = keypoints_object.toarray(); keypoint[] _keypoints_scene = keypoints_scene.toarray(); (int = 0; < good_matches.size(); i++) { obj.add(_keypoints_object[good_matches.get(i).queryidx].pt); scene.add(_keypoints_scene[good_matches.get(i).trainidx].pt); } matofpoint2f _obj = new matofpoint2f(); _obj.fromlist(obj); matofpoint2f _scene = new matofpoint2f(); _scene.fromlist(scene); **mat h = calib3d.findhomography(_obj, _scene, calib3d.ransac, 3);** ....
no error during compiling, have declared 2d point
matofpoint2f
, compiler accepted, when run code throws exception. reason, opencv bug or code has problem?
if knows please tell me how solve. in advance!
if (obj.isempty() || scene.isempty()) { logger.debug("no matches found @ all....."); }
the list of obj or scene empty. try avoid findhomography when list empty.
Comments
Post a Comment