from drawMatches function i get a matches keyoint image.
and then i tried for to localize object,so i try to use point2fvector.
//-- Localize the object
Point2fVector obj = new Point2fVector();
Point2fVector scene = new Point2fVector();
for( int i = 0; i < listofgoodmatches.size(); i++)
{
obj.push_back(k_modelPoint.get(listofgoodmatches.get(i).queryIdx()).pt() );
scene.push_back(k_objectPoint.get(listofgoodmatches.get(i).trainIdx()).pt());
}
//-- From here i try to pass point2fvector to mat
Mat imgObj = new Mat(obj); <= from here i passing point2fvector value(obj) through mat constructor it doesn't throught a exception?.
Mat imgScene = new Mat(scene);
Mat H = findHomography(imgObj,imgScene); <= from this i get a fatal error
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007fe477b8bd5c, pid=7339, tid=7343
#
# JRE version: OpenJDK Runtime Environment (11.0.8+10) (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1)
# Java VM: OpenJDK 64-Bit Server VM (11.0.8+10-post-Ubuntu-0ubuntu118.04.1, mixed mode, sharing, tiered, compressed oops, g1 gc, linux-amd64)
# Problematic frame:
# C [libopencv_calib3d.so.4.4+0x102d5c] cv::findHomography(cv::_InputArray const&, cv::_InputArray const&, int, double, cv::_OutputArray const&, int, double)+0xdc
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport %p %s %c %d %P %E" (or dumping to /home/mssindia/IdeaProjects/JavacppGpu/core.7339)
#
# An error report file with more information is saved as:
# /home/mssindia/IdeaProjects/JavacppGpu/hs_err_pid7339.log
#
# If you would like to submit a bug report, please visit:
# https://bugs.launchpad.net/ubuntu/+source/openjdk-lts
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
You'll need to pass it the data, something like this:
Mat imgObj = new Mat(1, obj.size(), CV_32FC2, obj.get(0));
Mat imgScene = new Mat(1, scene.size(), CV_32FC2, scene.get(0));
Mat imgObj = new Mat(1, obj.size(), CV_32FC2, obj.get(0));
Mat imgScene = new Mat.............
when i assign the above constructor of mat it shows cannot resolve constructor mat
and i changed the second argument value to byte.
Mat imgObj = new Mat(1, (byte)obj.size, CV_32FC2, obj.get(0));
Mat imgScene = new Mat(1, (byte)scene.size, CV_32FC2, obj.get(0));
it doesn't shows an error.
but when i try to pass the mat object value to parameter of findHomography function.
findHomography(imgObj,imgScene);
Exception in thread "main" java.lang.RuntimeException: OpenCV(4.4.0) /home/travis/build/javacpp-presets/opencv/cppbuild/linux-x86_64-gpu/opencv-4.4.0/modules/calib3d/src/fundam.cpp:372: error: (-5:Bad argument) The input arrays should be 2D or 3D point sets in function 'findHomography'
at org.bytedeco.opencv.global.opencv_calib3d.findHomography(Native Method)
at SurfGpu.main(SurfGpu.java:158)
It looks like that function wants a column vector like this:
https://github.com/bytedeco/javacv/blob/master/src/main/java/org/bytedeco/javacv/ObjectFinder.java#L180
ok i try this!,
since i changed second argument convert to int.
Mat imgObj = new Mat(1, (int)obj.size, CV_32FC2, obj.get(0));
Mat imgScene = new Mat(1, (int)scene.size, CV_32FC2, scene.get(0));
now i pass mat object to findHomography it doesn't shows runtime exception.