Ask Your Question
2

Documentation for opencv_annotation

asked 2015-11-01 11:50:44 -0600

Ofro04 gravatar image

Can anyone explain how the opencv_annotation tool works. I can't find any documentation. I have it loading the images, but I can't apply my selection or select multiple regions

edit retag flag offensive close merge delete

Comments

BTW, we have a tutorial for all objdetectrelated tools: http://docs.opencv.org/master/dc/d88/...

mshabunin gravatar imagemshabunin ( 2016-12-05 06:10:01 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
6

answered 2016-01-11 09:03:31 -0600

updated 2016-12-05 02:50:40 -0600

I kind of missed this topic so I would be glad to help you out with the annotation tool since it is of my making.

The following steps could be used to annotate images using the tool provided. I will examples how to run it from command line in Ubuntu, Linux, but it can generalize to other systems also.

Make sure that you have the option BUILD_opencv_apps selected during the built process of OpenCV and that you have performed a sudo make install so that your installation knows the tools! Then the following steps will do the trick.

  1. Create a folder with images that need to be annotated.
  2. Call the application on your data opencv_annotation -images /data/image_folder/ -annotations /data/annotations.txt. Keep in mind that the tool loves absolute paths, since relative paths can screw up the processing.
  3. The tool will open up the first image from the folder. However, since listing files inside a folder is system specific, it might be possible that it is not the first image you see. Since we need to process each and every image in the foldder, this is no problem at all.
  4. Use your mouse to select a region of interest, keeping the borders as close as possible to the actual object your want to train a model for. When you are okay with the annotation, press the c key on your keypad to confirm. You will see the red annotation turn to green.
  5. Continue untill all objects in the image are annotated.
  6. Press the n key on your keyboard to load the next image.
  7. If you want to shut down the annotation tool, press the ESC key.

Your results will be stored in the text file as follows image_location number_annotations x0 y0 w0 h0 x1 y1 w1 h1 ... xN yN wN hN with N+1 being the amount of annotations, since we start calculating at 0 index.

UPDATE:

Due to a recent PR, the command line parser interface of OpenCV has been integrated into OpenCV annotation, and now one would need to use the new improved command for passing arguments, which is:

opencv_annotation --images=/data/image_folder/ --annotations=/data/annotations.txt

edit flag offensive delete link more

Comments

hi. I wrote the following code:

#include "cmd_utils.h"
#include <iostream>

#define PICS_PATH "/home/biagio/Documenti/wise_robotics/annotations/build/data/image_folder/"
//#define PICS_PATH "/data/pics/"
#define ANNOTATIONS_PATH "/home/biagio/Documenti/wise_robotics/annotations/build/data/annotations.txt"
//#define ANNOTATIONS_PATH "/data/annotations.txt"
#define ANNOTATIONS_CMD "opencv_annotation -images " PICS_PATH " -annotations " ANNOTATIONS_PATH

using namespace std;

int main()
{
    //remove(ANNOTATIONS_PATH);

    execute_command(ANNOTATIONS_CMD);
}

I used the same structure for /data, a local folder. absolute paths seem correct but I get

The image folder given does not exist.

why so?

biagio montesano gravatar imagebiagio montesano ( 2016-12-03 10:57:53 -0600 )edit

folder exists, of course and has right name

biagio montesano gravatar imagebiagio montesano ( 2016-12-03 10:58:47 -0600 )edit

Probably because you are using the most recent version of OpenCV, where the official command line parser has been integrated. There we would ask you to provide the data as follows: opencv_annotation --images=/data/image_folder/ --annotations=/data/annotations.txt

StevenPuttemans gravatar imageStevenPuttemans ( 2016-12-05 02:48:29 -0600 )edit
1

thanks a lot, it worked. I see you've added a revision to your original post, I'm glad of having been useful with my question :))))) thanks again.

biagio montesano gravatar imagebiagio montesano ( 2016-12-05 09:14:30 -0600 )edit

one more question: if I stop the process, by pressing ESC, after labelling N images and restart it, does it begin again from first image or does it continue from image N+1?

biagio montesano gravatar imagebiagio montesano ( 2016-12-05 09:43:15 -0600 )edit

Euhm it will start just over, because it would be another complexity to remember in a file where it last passed. It does store the detections when pressing ESC, so you could just make a cropped folder and continue on that one.

StevenPuttemans gravatar imageStevenPuttemans ( 2016-12-07 02:32:40 -0600 )edit

yes, that's what I was thinking. a nice improvement would be to resize each rectangle after drawing it on image, before pressing C to confirm it. in fact, it's not easy to crop image with rectangle at first attempt. using dragable corners to size properly area of interest, would make things easier. do you think it may possible?

thanks for your patience and support.

biagio montesano gravatar imagebiagio montesano ( 2016-12-07 02:43:50 -0600 )edit

Thats not possible using the available OpenCV interfaces, since the library is not meant to do heavy user interfacing. For that one would need extra functionality.

StevenPuttemans gravatar imageStevenPuttemans ( 2016-12-07 02:49:44 -0600 )edit

I am have python-opencv installed and opencv_samples works fine but when i do opencv_annotation command it says command not found. please help

snehal.chemburkar gravatar imagesnehal.chemburkar ( 2017-04-05 12:37:00 -0600 )edit

I do not think that this functionality is available from python, especially since the tools are not wrapped into python. It is not a sample, for which specific python samples exist, rather a tool that we provide which heavily depends on the C++ functionality to build your models seperately which can then be used to detect stuff, even in python.

StevenPuttemans gravatar imageStevenPuttemans ( 2017-04-06 02:19:39 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2015-11-01 11:43:48 -0600

Seen: 14,564 times

Last updated: Dec 05 '16