cleanup
This commit is contained in:
parent
cccd0f1641
commit
f60ffee0bb
3 changed files with 16 additions and 15 deletions
|
|
@ -1,17 +1,15 @@
|
||||||
cmake_minimum_required(VERSION 2.8)
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
|
||||||
set(PROJECT "integral_image")
|
set(PROJECT "integral_image")
|
||||||
set(PROJECT_TESTS tests)
|
set(PROJECT_TESTS ${PROJECT}_tests)
|
||||||
|
|
||||||
include(CTest)
|
include(CTest)
|
||||||
|
|
||||||
find_package(OpenCV REQUIRED)
|
find_package(OpenCV REQUIRED)
|
||||||
|
|
||||||
find_package(OpenMP REQUIRED)
|
find_package(OpenMP REQUIRED)
|
||||||
if (OPENMP_FOUND)
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,10 @@
|
||||||
namespace integral_image {
|
namespace integral_image {
|
||||||
|
|
||||||
|
|
||||||
|
//TODO: The algorithms do not require the data to be of 'double' type.
|
||||||
|
//Consider to turn functions into template functions.
|
||||||
|
|
||||||
|
|
||||||
using Mat = cv::Mat_<double>;
|
using Mat = cv::Mat_<double>;
|
||||||
|
|
||||||
//! A reference serial implementation of the integral image algorithm.
|
//! A reference serial implementation of the integral image algorithm.
|
||||||
|
|
|
||||||
19
main.cpp
19
main.cpp
|
|
@ -10,7 +10,6 @@
|
||||||
#include "integral_image.h"
|
#include "integral_image.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -64,7 +63,7 @@ Arguments parse_arguments(int argc, char **argv)
|
||||||
std::ostream &operator<<(std::ostream &os, const integral_image::Mat &mat)
|
std::ostream &operator<<(std::ostream &os, const integral_image::Mat &mat)
|
||||||
{
|
{
|
||||||
//The specification doesn't require any precision or data presentation format,
|
//The specification doesn't require any precision or data presentation format,
|
||||||
//so here we use a default one
|
//so here we use default ones
|
||||||
|
|
||||||
if (mat.data) {
|
if (mat.data) {
|
||||||
|
|
||||||
|
|
@ -107,7 +106,7 @@ int main(int argc, char **argv)
|
||||||
mat.release();
|
mat.release();
|
||||||
|
|
||||||
|
|
||||||
auto output_file_name = file_name + OUTPUT_FILE_POSTFIX;
|
const auto output_file_name = file_name + OUTPUT_FILE_POSTFIX;
|
||||||
std::fstream fs(output_file_name, std::ios_base::out);
|
std::fstream fs(output_file_name, std::ios_base::out);
|
||||||
if (fs.bad()) {
|
if (fs.bad()) {
|
||||||
|
|
||||||
|
|
@ -115,19 +114,19 @@ int main(int argc, char **argv)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &channel : channels) {
|
for (const auto &channel : channels) {
|
||||||
|
|
||||||
using namespace integral_image;
|
using namespace integral_image;
|
||||||
|
|
||||||
//The specification implicitly assumes that an output consists of floating-point values.
|
//The specification implicitly assumes that an output file consists of floating-point values.
|
||||||
//Since the reasons of that decision are unknown, we convert data to 'double' format before
|
//Since the reasons of that decision are unknown, we convert data to 'double' format before
|
||||||
//calculations. Pros: no overflow, cons: precision loss.
|
//calculations. Pros: no overflow, cons: precision loss, slower calculations.
|
||||||
Mat float_channel;
|
Mat float_mat;
|
||||||
channel.convertTo(float_channel, CV_64FC1);
|
channel.convertTo(float_mat, CV_64FC1);
|
||||||
|
|
||||||
float_channel = integral_image_openmp(float_channel, args.thread_number);
|
float_mat = integral_image_openmp(float_mat, args.thread_number);
|
||||||
|
|
||||||
fs << float_channel;
|
fs << float_mat;
|
||||||
if (fs.fail()) {
|
if (fs.fail()) {
|
||||||
|
|
||||||
std::cerr << "Failed to write data to file " << output_file_name << std::endl;
|
std::cerr << "Failed to write data to file " << output_file_name << std::endl;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue