C++ Dlib load_image_dataset issues

1k views Asked by At

When loading a set of images using dlibs load_image_dataset as so:

//------------
command_line_parser parser; 
parser.parse(argc, argv); //inputs argc, argv as defined by main where argv is an .xml containing all file locations

dlib::array<array2d<rgb_pixel> > images;
std::vector<std::vector<rectangle> > object_locations, ignore;

cout << "Loading image dataset from metadata file " << parser[1] << endl;
ignore = load_image_dataset(images, object_locations, parser[1]);
cout << "Number of images loaded: " << images.size() << endl;
//---------------

I get the following error:

"dlib::array2d<T, mem_manager> &dlib::array2d<T, mem_manager>::operator=(dlib::array2d<T, mem_manager> &) [with T=dlib::rgb_pixel, mem_manager=dlib::default_memory_manager]" (declared at line 320 of "C:\..path-to-dlib...\dlib-18.16\dlib\..\dlib/image_processing/../image_processing/../matrix/../array2d/array2d_kernel.h") is inaccessible

If I try to store an individual image from "images" as so:

//--------
array2d<rgb_pixel> img;
img = images[i];
//-----------

But no error if i just display it:

//------
image_window image_i(images[i], "Image i");
//---------

What is happening and how do I fix it?

1

There are 1 answers

1
Davis King On BEST ANSWER

array2d is non-copyable by design because copying images is expensive and almost always unnecessary. If you want to move an image around use swap(). If you really need to copy an image then you can use the assign_image() function or you can use matrix objects (which are copyable) to represent images instead of array2d.

But really, don't unnecessarily copy images.