Using the opencv_annotation program to annotate your positive images
opencv_annotations - Tips
The opencv_annotations tool is a very helpful in helping you capture all of the rectangular coordinates for all of the positive samples you would like to use in your cascade training. Rectangle coordinate means (x,y,w,h). The program will generate a text file that contains the
- file path to the positive image
- the number of images (count is usually 1)
- the Rectangle coordinates means (x,y,w,h)
The program is not the most user friendly. You just need someone like myself to guide you through it. It is very helpful tool. It is called opencv_annotations, because it is describing some information about each positive image in your positive samples. Lets walk through the program execution.
opencv_annotations -images ./images –annotations annotations.txt
Some important tips. The program will run and attempt to open every file in the ./images directory. If it encounters anything but an image it will through an exception and terminate. If there is a corrupt image it will terminate. That is why I run it from the parent directory of the image path and double check your images are in good shape.
When launched properly, the program will display a preview of the image.
- Your job is to use the mouse and click at the point where the start of the rectangle coordinates are and drag until the full positive image is displayed. Then let go. This will capture the coordinates behind the scenes. It does not matter where you click to start drawing the rectangle. The program will record the correct rectangle coordinates.
- Next press on the “c” key to confirm the recording of the rectangle coordinates.
- Next press on the “n” key to move to the next image.
- Repeat steps 1 through 3 for all the images you want to annotate.
The program terminates when there are no more images to be displayed or when you hit the “esc” button. It is at that point in time that it writes the positive image file name and the rectangular coordinates you selected for each image to the annotations file you specified.
Now you should know everything you need to know about this simple but effective tool.