Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Description Data Persistence #10

Open
gushenjie opened this issue Aug 29, 2021 · 3 comments
Open

Feature Description Data Persistence #10

gushenjie opened this issue Aug 29, 2021 · 3 comments

Comments

@gushenjie
Copy link

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?

@EnoxSoftware
Copy link
Owner

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

@gushenjie
Copy link
Author

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
Copy link
Author

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants