AndrewCarterUK / pascal-voc-writer

A python library for generating annotations in the PASCAL VOC format.
MIT License
220 stars 57 forks source link

multiple bbox information is not added #5

Closed RiyazAtar closed 4 years ago

RiyazAtar commented 4 years ago

if we have more classes in single image , then it adds only one class information.

shrnssh commented 4 years ago

That's because you need to call the 'Writer' function and the 'writer.save' function once. You can call the writer.addObject() any number of times between the first two

tanajikamble13 commented 4 years ago

@shrnssh I am not getting how to do that in my program. If I call writer save function multiple times it will overwrite the existing bounding box info.

AndrewCarterUK commented 4 years ago
writer = Writer('path/to/img.jpg', 800, 400)

writer.addObject('cat', 100, 100, 200, 200)
writer.addObject('dog', 300, 300, 400, 400)
writer.addObject('ball', 50, 50, 75, 75)

writer.save('path/to/img.xml')
AndrewCarterUK commented 4 years ago

Think this should answer the question, please comment again if you'd like me to reopen.

tanajikamble13 commented 4 years ago

I am using this library to convert annotation from text format to Pascal format. In text file each line represent path of image and bounding bound box values for single object. Now, If image consist of multiple of objects, then for single image in text file multiple lines will be there for each bounding box. I access each line individually to create xml file. Suppose image im1.jpg consist of 3 objects thesn as given below 3 boxes will be there as shown below

im1.jpg;1030;441;1050;461;5 im1.jpg;375;407;411;443;5 im1.jpg;1273;381;1313;421;5

here as i am saving file 3 times my old xml file gets overwritten instead of appending the new object. Thanks

AndrewCarterUK commented 4 years ago

Hi @tanajikamble13 - you'll need to write your program in a way that ensures all of the objects you need are known before you call save().

ibragimoveldor commented 4 years ago

Hi, how to write multibox in one image with single class type?