This project is a simple C++ program that parses command line arguments to set an input directory and an output directory. It loads all image files from the input directory using OpenCV, calculates the mean RGB values using NVIDIA NPP, resizes the images to 32x32 pixels, and saves the processed images to the output directory with a .png
extension.
- C++17 compiler
- OpenCV library
- NVIDIA NPP library
- make
- Install OpenCV:
# For Ubuntu, to install opencv developer library:
sudo apt install libopencv-dev
- Install NVIDIA NPP (Usually installed with CUDA library)
-
data/ contains scripts that download images from Google's Open Image Dataset (validation) subset
-
subset-val.csv contains information about 100 files This file was created by
head validation-images-with-rotation.csv -n 100 >subset-val.csv
, where validation-images-with-rotation.csv is from https://storage.googleapis.com/openimages/web/download_v7.html - in Image IDs Validation set. -
First cd into
cd data
-
./csv-to-download-format.sh subset-val.csv >subset.txt
will convert to txt format -
python3 downloader.py subset.txt --download_folder ./images/
will download images
-
Clone the repository:
git clone https://github.com/mastershin/cuda-2d-image-prep-example/ cd cuda-2d-image-prep-example
-
Build the project:
make
Alternatively, you can compile the project using g++
:
g++ -std=c++17 -I$(pkg-config --cflags opencv4) -L$(pkg-config --libs opencv4) -L/path/to/npp/lib -lopencv_core -lopencv_imgcodecs -lopencv_imgproc -lnppicc -lnppif -o image_processor ../image_processor.cpp
./bin/image_processor --directory ./data/images/
./bin/image_processor --directory ./data/images/ --output ./output/ --width 32 --height 32