-2
I need to make a script to run the command below on the terminal several times:
opencv_createsamples -img toras/toras_00001.jpg -bg negativas/negativas.txt -info positivas1/positivas1.txt -maxxangle 0.5 -maxyangle 0.5 -maxzangle 0.5 -num 100 -bgcolor 0
What will change each time the command runs are these parameters:
-img toras/toras_00001.jpg
-info positivas1/positivas1.txt
Where it’s 1, turn 2, 3, 4, 5... up to 492
Does anyone have any idea how to do?
Making a comparison with C++, I believe it’s something like:
for(int i = 1; i <= 492; i++)
{
opencv_createsamples -img "toras/toras_0000"+to_string(i)+".jpg" -bg negativas/negativas.txt -info "positivas"+to_string(i)+"/positivas"+to_string(i)+".txt" -maxxangle 0.5 -maxyangle 0.5 -maxzangle 0.5 -num 100 -bgcolor 0
}
But I haven’t figured out how to write something like this in bash...
https://pastebin.com/0HY1crw7
– Valdeir Psr
Thank you so much for your help. Pardon ignorance, but how did you do it? My question is very basic for someone to negatively??
– zampnrs
I used the command
seq
to generate a sequence of 0 to 492; To form the value 00001, I used theprintf
, to the Zero-Padding. In this command, define that it will have to complement with the number "0" until completing 4 digits (0001, 0010, 0100, 1000). P.S.: Ofor
works just like in Golang. It will go through all the values generated byseq
– Valdeir Psr
About the negative votes, I don’t know why (I didn’t negatively). Perhaps people did not understand the question and resolved to negatively; or perhaps it is for other reasons. I recommend the link https://pt.meta.stackoverflow.com/search?q=qnegativo. About the closing vote, I honestly did not understand. The question is within the scope.
– Valdeir Psr
I got it, very good your reasoning for generating the number, I hadn’t thought of that. I had thought about using conditionals, but it would be more work, and I have no idea how to program in bash. I only made a modification on: filename=$(printf %04d $i), I replaced 4 by 5. It worked perfectly, thank you very much!
– zampnrs