-4

I am using LabView and OpenCV to load a an unknown amount of 2D-Pictures from a folder (16 Bit Signed) in LabView and then give it to OpenCV where you do s.th. with it, afterwards send it back to LabView.

Here is my approach, but it didn't work, hope you can help me?

VI

Code

UPDATE:

The only thing that did not give me the right pixel value is how to access the 3D-Array from LabView.

Code V2

VI V2

Call Lib Function

tunnel mode

Xeno1987
  • 9
  • 1
  • 6
  • Use [glob](http://stackoverflow.com/a/26536198/5008845) – Miki Mar 08 '16 at 13:44
  • Thanks, but I have to load the images first of all in LabView not OpenCV. – Xeno1987 Mar 08 '16 at 13:54
  • So something like [this](https://lavag.org/topic/10624-how-to-read-all-text-files-in-folder/)? (just a quick google search, I've no idea of how labview works) – Miki Mar 08 '16 at 13:58

2 Answers2

0

You are reading only one image: only a single path and a single IMAQ image are going out from the for loop.

My suggestion: put IMAQ Read file function in the for loop and enable autoindexing for the IMAQ image (remember to change image name at each iteration of the for loop).

Then you can apply your OpenCV function on each of the read images.

MarcoM
  • 1,093
  • 9
  • 25
-1

you can use a std::vector containing the path for the group of images.

you can use a function like the below, to fill the vector, with the relative path to the images:

std::vector<std::String> imagelistVector(std::string path)
{
    std::vector<std::String> fn;
    cv::glob(path,fn,false);
    return fn;
}

that makes use of the cv::glob template

the usage e.g.:

vector<String> imglist=imagelistVector("data/*.jpg");

will read all the images with the .jpg extension in the local "data" folder

Then you can use the list to read all the images, by the use of a for loop like that:

for (unsigned int i =0; i<imglist.size(); i++)
{
  Mat img = imread(filelist.at(i), CV_LOAD_IMAGE_COLOR);
  //do something with each image
}

Or if you want to store all the images:

std::vector<cv::Mat> images;
for (unsigned int i =0; i<imglist.size(); i++)
{
  Mat img = imread(filelist.at(i), CV_LOAD_IMAGE_COLOR);
   images.push_back(img)
}
//do something with all or a group of images
  • OP asked (in comments) how to do this in LabView, not OpenCV (in which case, closing as duplicate would have been the better choice. There are a lot of answers that already show how to use `glob`). – Miki Mar 08 '16 at 14:15