MarkerLessARExample icon indicating copy to clipboard operation
MarkerLessARExample copied to clipboard

Feature Description Data Persistence

Open gushenjie opened this issue 4 years ago • 3 comments

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?

gushenjie avatar Aug 29 '21 10:08 gushenjie

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());

EnoxSoftware avatar Aug 30 '21 09:08 EnoxSoftware

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?

gushenjie avatar Aug 31 '21 01:08 gushenjie

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?

gushenjie avatar Aug 31 '21 01:08 gushenjie