Open.CV Error Save File

Asked

Viewed 40 times

0

Good morning guys, I have the following code:

var faceImage = new Image<Gray, byte>(new Bitmap(bm));
                imagensFace[i] = faceImage.Resize(100, 100, Inter.Cubic);
                faceLabels[i] = todasFaces[i].ID;
            }
            faceRecognizer.Train(imagensFace, faceLabels);
            faceRecognizer.Save("C:/Temp");

however when passing the part that saves the faceRecognizer is pointed out the following error: Emgu.CV.Util.Cvexception: 'Opencv: File can’t be opened for writing!'

Below is the faceRecognizer statement:

FaceRecognizer faceRecognizer = new EigenFaceRecognizer(80, double.PositiveInfinity);

If anyone can help me I’d appreciate it.

1 answer

2


It may be that the library can interpret the / in the file path, but the normal is \.

You can try:

faceRecognizer.Save("C:\\Temp");

or

faceRecognizer.Save("C:\\Users\\User\\Documents\\Emgu\\Teste.yml");

another (most likely) situation is that, as you are saving in C:, the operating system asks for upgrade of privileges, you can resolve this by changing the location where you will save the file, by placing on documents, images, desktop... or elevating the execution of the visual studio, the famous Executar como administrador

  • I am saving in "C: Users User Documents Emgu" but the error persists, I tried to run as administrator and also not solved :/

  • the same error ? by chance, you open the file for reading another snippet of the code ? if yes, post the snippet as well. @Brayan

  • I don’t really open it anywhere, because I need to make it be saved first so that later I open it

  • I changed the answer, try to do the second way, and in case of error, put the stacktrace here @Brayan

  • Rovan got it, in fact it was missing by the file extension name for example "C: Temp Teste.xml" even so, thank you very much for the attention :D

  • 1

    Ops didn’t see, it’s exactly the answer you changed, only with extension . xml

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.