Mat to String and back in OpenCV4Android
I am doing face recognition using opencv4android and JavaCV.
I did the face detection in OpenCV and created the LBP histogram through JavaCV Face Recognizer class. Now I want to save this histogram in a database.
The histogram itself is in the Matvector type, considering I am saving the model into an xml file using the model.save() method. Then I parse the xml and take the histogram into string.
I want to use opencv4android method compareHist(Mat,Mat,int) for comparison so I need to convert this string back to Mat.
How can i do it using OpenCV4andorid?
Can I ask why you would want to parse an xml file into a string, then parse it back? Basically when storing the model (I am guessing here you are talking about the LBP histogram) by using the save functionality, you can just simple load in the xml file again by using the load functionality. XML files are highly optimized for storage, so why trying to parse that?
I want to send the string to another application and save it in database. The application can only accept it as a string. Now I can convert it to a string by first using the getCVmat of model to extract the Matrix at specific location and then .toString() of CVmat to extract the content of matrix as string. But now I want to convert this string to OpenCV4android Mat type.
Then you will have to read in the data from the string, seperate it based on a seperation character and then add it manually into a matrix object. This isn't done by the openCV code, but by standard C ++ libraries.
yes, I am trying to split the string into string array and converting each sub string into double. After I can use the Mat.put(0,0, double) for filling the matrix. and that could be the possible solution.