Open gushenjie opened 3 years ago
OpenCVForUnity does not have a way to directly save Mat values to a text file. However, it is possible to save the Mat as an image file.
MatOfKeyPoint keypoints1 = new MatOfKeyPoint ();
Mat descriptors1 = new Mat ();
detector.detect (img1Mat, keypoints1);
extractor.compute (img1Mat, keypoints1, descriptors1);
Debug.Log("descriptors1.ToString() " + descriptors1.ToString());
Debug.Log("descriptors1.dump() " + descriptors1.dump());
Imgcodecs.imwrite("C:/Users/satoo/Desktop/des.png", descriptors1);
Mat loadDes1 = Imgcodecs.imread("C:/Users/satoo/Desktop/des.png", Imgcodecs.IMREAD_GRAYSCALE);
Debug.Log("loadDes1.ToString() " + loadDes1.ToString());
Debug.Log("loadDes1.dump() " + loadDes1.dump());
Sorry, using the method you gave, the program feature point matching is always 0, but I used the MAT to JSON format to save the descriptors as a txt file, and the function is normal. Now I still want to save the keypoints data together, and I am still trying. Do you have any good suggestions?
OpenCVForUnity does not have a way to directly save Mat values to a text file. However, it is possible to save the Mat as an image file.
MatOfKeyPoint keypoints1 = new MatOfKeyPoint (); Mat descriptors1 = new Mat (); detector.detect (img1Mat, keypoints1); extractor.compute (img1Mat, keypoints1, descriptors1); Debug.Log("descriptors1.ToString() " + descriptors1.ToString()); Debug.Log("descriptors1.dump() " + descriptors1.dump()); Imgcodecs.imwrite("C:/Users/satoo/Desktop/des.png", descriptors1); Mat loadDes1 = Imgcodecs.imread("C:/Users/satoo/Desktop/des.png", Imgcodecs.IMREAD_GRAYSCALE); Debug.Log("loadDes1.ToString() " + loadDes1.ToString()); Debug.Log("loadDes1.dump() " + loadDes1.dump());
Sorry, using the method you gave, the program feature point matching is always 0, but I used the MAT to JSON format to save the descriptors as a txt file, and the function is normal. Now I still want to save the keypoints data together, and I am still trying. Do you have any good suggestions?
p.savetxt(outputImgPath ,des , fmt='%.2f')
Python code saves image features and sample code. How does unityforopencv persist image features, including saving and reading? Do you give some suggestions and guidance?