diff --git a/INSTALL b/INSTALL index 3642a5c..d15b5d5 100644 --- a/INSTALL +++ b/INSTALL @@ -5,21 +5,21 @@ Dependencies - CUDA (>= 4.0) (Not required for the CPU-only feature extractor). - HDF5 (>= 1.8.11) - Download the source code http://www.hdfgroup.org/ftp/HDF5/prev-releases/hdf5-1.8.12/src/hdf5-1.8.12.tar.gz + Download the source code http://www.hdfgroup.org/ftp/HDF5/releases/hdf5-1.8.16/src/hdf5-1.8.16.tar.gz To install locally - $ ./configure --prefix=~/local/ --enable-threadsafe --with-pthread=/usr/include - $ make + $ make -j7 $ make install - Protocol Buffers (>= 2.5.0) - Download the source code https://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz + Download the source code https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gz To install locally - $ ./configure --prefix=~/local/ - $ make + $ make -j7 $ make install - OpenCV - Download the source code https://github.com/Itseez/opencv/archive/3.0.0-alpha.zip + Download the source code https://github.com/Itseez/opencv/archive/3.1.0.tar.gz To quick install - $ cmake-gui, set CMAKE_BUILD_TYPE to Release $ cd build directory @@ -29,6 +29,7 @@ Dependencies - libjpeg This is often present on standard operating systems since it is used by a lot of programs. It can be downloaded from http://libjpeg.sourceforge.net/ + For Ubuntu: sudo apt-get install libjpeg-dev - This code uses C++11. Some features require gcc >= 4.6. diff --git a/src/image_iterators.cc b/src/image_iterators.cc index 79115f4..0ff3ba9 100644 --- a/src/image_iterators.cc +++ b/src/image_iterators.cc @@ -63,13 +63,11 @@ void getData(Mat &image, T* data_ptr) { int num_pixels = image.cols * image.rows; if (num_image_colors >= 3) { // Image has 3 channels. // Convert from opencv Mat to format: "rr..gg..bb". - unsigned int base1 = num_pixels; - unsigned int base2 = 2 * num_pixels; for (int j=0, posr=0; j < image.rows; ++j, posr+=image.cols) { - unsigned int offset0 = posr; - unsigned int offset1 = base1 + posr; - unsigned int offset2 = base2 + posr; - char *imgr = image.ptr(j); + unsigned int offset0 = posr; + unsigned int offset1 = posr + num_pixels; + unsigned int offset2 = posr + 2 * num_pixels; + unsigned char *imgr = image.ptr(j); for (int k=0, posc=0; k < image.cols; ++k, posc+=3) { data_ptr[offset0 + k] = imgr[posc+2]; data_ptr[offset1 + k] = imgr[posc+1]; @@ -77,8 +75,17 @@ void getData(Mat &image, T* data_ptr) { } } } else if (num_image_colors == 1) { // Image has 1 channel. - for (int i=0; i < 3; ++i) { - memcpy(data_ptr + i * num_pixels, image.data, num_pixels * sizeof(T)); + // Convert from opencv Mat to format: "rr..gg..bb". + for (int j=0, posr=0; j < image.rows; ++j, posr+=image.cols) { + unsigned int offset0 = posr; + unsigned int offset1 = posr + num_pixels; + unsigned int offset2 = posr + 2 * num_pixels; + unsigned char *imgr = image.ptr(j); + for (int k=0; k < image.cols; ++k) { + data_ptr[offset0 + k] = imgr[k]; + data_ptr[offset1 + k] = imgr[k]; + data_ptr[offset2 + k] = imgr[k]; + } } } else { cerr << "Image has " << num_image_colors << "colors." << endl;