Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.

Expand Down
23 changes: 15 additions & 8 deletions src/image_iterators.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,29 @@ 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<char>(j);
unsigned int offset0 = posr;
unsigned int offset1 = posr + num_pixels;
unsigned int offset2 = posr + 2 * num_pixels;
unsigned char *imgr = image.ptr<unsigned char>(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];
data_ptr[offset2 + k] = imgr[posc ];
}
}
} 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<unsigned char>(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;
Expand Down