-1

I have used JavaCv (and opencv too) to implement live face detection preview on Android. I work ok. Now I want to take a picture or record a video from live preview which have face detection (I mean when I take a picture, this picture will have a person and a rectangle around his/her face). I have researched a lot but get no result. Can anyone help me please !!!

CodeMonster
  • 300
  • 5
  • 19

1 Answers1

0

What you're looking for is the imwrite() method.

Since your question isn't clear on the use-case, I'll give a generic algorithm, as shown:

imwrite writes a specified Mat object to a file and it accepts 2 arguments - fileName and Mat object, for example - imwrite('output.jpg',img);

Here's the logic you can follow:

  • Receive input frame (Mat input from video and run face detection using your existing method.

Draw a rectangle on an output image (Mat output).

Use imwrite as - imwrite('face.jpg',output)

In case you want to record all the frames with a face in them, replace 'face.jpg' with a string variable that is updated with each loop iteration and run imwrite in a loop

If you wish to record a video. Have a look at VideoWriter() class

Community
  • 1
  • 1
Saransh Kejriwal
  • 2,467
  • 5
  • 15
  • 39