That's what the author of the script put there. Changing it doesen't work though, if I change it to 1 it only process one object.
Tyler Perry
Do you know what :-1 means?
Hudson Collins
>file.write(self.fill_template(object)) using loop variable why
Alexander Sanchez
Not in this context, no. I assume it means to run it until there is only one match left or something along those lines? Changing it to one makes it only process the first object regardless of how many is in the file. Then line 51 for some reason also runs, so in xml files with only one object it spits out two lines..
This works though. I removed any number from the for loop and deleted line 51. Although now it also include a newline in the converted output txt when the xml file only have one object. I don't know if this matters though, I'll have to try!
I just perused the test data the original author put up and it obviously wasn't properly checked by the author because there's a clear error in the output.
Isaac Rivera
Change line 51 to be the following:
file.write(self.fill_template(objects[-1]))
It looks like the code basically loops over all objects, doing the template translation. For all object EXCEPT the last object in the list, they also want to append a new line character (last object will have an EOF appended when the file is closed).
This is suspiciously bad code, but I be the above will make it work.
Nolan Barnes
>because there's a clear error in the output.
What kind of error is that?
Is it that the label is put in as a string and not a number? I'm not familiar with the KITTI format.
Colton Thomas
The :-1 means all the elements in the array except the last one. When you have one element in the array it returns a zero length slice so it can't fill the object variable. Worse, though, when the length of the array is greater than one it'll loop the length of the entire array, but the final iteration will use the previous iterations data because there's no element in the slice that coincides with that iteration. So if you look in the test text files in that github you'll find the last two lines are identical.
Ethan Moore
you are trying to call object before giving it a value
Jackson Gomez
>Change line 51 to be the following: >file.write(self.fill_template(objects[-1]))
That seems to work, no extra newline in the output either! Thanks!
That makes sense, you're right. This seems to take care of that, I tried it on the test data it seems to spit out correct output.
Gavin Edwards
I'm gonna go try this out now, thanks for the help anons. I've learned something new today, which is always great. :)
Robert Murphy
objects[:-1] is an empty list if objects is length 1. [:-1] means all but the last element.