pimmes111
pimmes111

Reputation: 200

set image path with createTrackbar

I'm working on an OpenCV project and need to complete a lot of tests. Therefore I want to create some sort of a GUI with some trackbars so I can run these tests more efficient. (ofcourse I can run them 1 by 1 but that will cost a lot of time and isn't very efficient)

For example I'm using this line of code where I load a .jpg image as a matrix:

Mat testSample = imread("test-01/subject-01_01.jpg");

Is it possible to insert all these "01" values with 3 seperate trackbars instead of hardcoding the path to the .jpg image.

I tried googling with "variable image path" but all searches point towards environment variables and that's not what I need. Can anyone provide me a useful link or some hints how to solve this problem.

Upvotes: 0

Views: 231

Answers (1)

sansuiso
sansuiso

Reputation: 9379

I have two propositions:

  1. link each trackbar to an integer variable (int testIdx, int subjIdx and int imgIdx), then use the class std::stringstream to generate the file name from your naming pattern, using trackbar callbacks for user interaction

  2. or write a non-intercative program that uses an input configuration file (such as my_file.xml or my_file.yml). OpenCV is able to handle these files, and you can easily create and populate them using shell scripts.

Upvotes: 1

Related Questions