Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Initial structure of the image_pipeline standalone library.

  • Loading branch information...
commit f5392f51f62c4b1a138153bc351c848b2d790f04 1 parent cf964f3
Ethan Rublee ethanrublee authored
31 CMakeLists.txt
... ... @@ -0,0 +1,31 @@
  1 +cmake_minimum_required(VERSION 2.8)
  2 +project(image_pipeline)
  3 +
  4 +if(NOT CMAKE_BUILD_TYPE)
  5 + set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING
  6 + "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
  7 + FORCE)
  8 +endif()
  9 +
  10 +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
  11 +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
  12 +
  13 +add_definitions("-Wall -Werror")
  14 +
  15 +find_package(Boost REQUIRED)
  16 +find_package(Eigen REQUIRED)
  17 +find_package(OpenCV REQUIRED)
  18 +
  19 +include_directories(
  20 + include
  21 + ${EIGEN_INCLUDE_DIRS}
  22 + ${Boost_INCLUDE_DIRS}
  23 + )
  24 +
  25 +add_subdirectory(src)
  26 +
  27 +option(BUILD_TEST "Build tests" ON)
  28 +if(BUILD_TEST)
  29 + enable_testing()
  30 + add_subdirectory(test)
  31 +endif()
30 include/image_pipeline/abi.hpp
... ... @@ -0,0 +1,30 @@
  1 +#pragma once
  2 +#include <stdexcept>
  3 +namespace image_pipeline
  4 +{
  5 + const static unsigned abi_version = 0; // incrementable ABI version
  6 +
  7 + // exception to be thrown in case of detected incompatiblity
  8 + struct incompatible_version : std::exception
  9 + {
  10 + unsigned compiled_version, running_version;
  11 + incompatible_version(unsigned compiledwith, unsigned runningwith);
  12 + virtual const char* what() const throw();
  13 + };
  14 +
  15 + // object that checks ABI version in its constructor
  16 + struct abi_checker {
  17 + abi_checker(unsigned version);
  18 + };
  19 +
  20 +// CMake will define foo_EXPORTS when compiling foo itself (and not
  21 +// when compiling *against* Foo. So this will save us a very small amount
  22 +// of space inside libfoo itself, but it doesn't hurt if they are there.
  23 +#ifndef image_pipeline_EXPORTS
  24 + // an instance of this object... there will be one in each
  25 + // translation unit that compiles against this header
  26 + namespace {
  27 + abi_checker checker(abi_version);
  28 + }
  29 +#endif //image_pipeline_EXPORTS
  30 +}
5 include/image_pipeline/image_pipeline.hpp
... ... @@ -0,0 +1,5 @@
  1 +#pragma once
  2 +#include <image_pipeline/abi.hpp>
  3 +namespace image_pipeline
  4 +{
  5 +}
1  readme.rst
Source Rendered
@@ -24,6 +24,7 @@ requires
24 24 * cmake
25 25 * Eigen3 http://eigen.tuxfamily.org/
26 26 * OpenCV > 2.3 http://opencv.willowgarage.com/wiki/
  27 +* *optional* gtest
27 28 * *optional* ecto https://github.com/plasmodic/ecto
28 29
29 30 build it
9 src/CMakeLists.txt
... ... @@ -0,0 +1,9 @@
  1 +
  2 +add_library(image_pipeline
  3 + abi.cpp
  4 + )
  5 +
  6 +target_link_libraries(image_pipeline
  7 + ${OpenCV_LIBS}
  8 + )
  9 +
21 src/abi.cpp
... ... @@ -0,0 +1,21 @@
  1 +#include <image_pipeline/abi.hpp>
  2 +#include <stdexcept>
  3 +
  4 +namespace image_pipeline {
  5 +
  6 + abi_checker::abi_checker(unsigned running_version)
  7 + {
  8 + if (running_version != abi_version)
  9 + throw incompatible_version(running_version, abi_version);
  10 + };
  11 +
  12 + incompatible_version::incompatible_version(unsigned c, unsigned r)
  13 + : compiled_version(c), running_version(r)
  14 + { }
  15 +
  16 + const char* incompatible_version::what() const throw() {
  17 + return "Runtime version ofimage_pipeline is incompatible with"
  18 + " the compiletime version of image_pipeline. Check "
  19 + "the contents of your runtime link path.";
  20 + }
  21 +}
21 test/CMakeLists.txt
... ... @@ -0,0 +1,21 @@
  1 +find_package(GTest)
  2 +
  3 +if(NOT GTEST_FOUND)
  4 + message(STATUS "Disabling testing since gtest was not found.")
  5 + return()
  6 +endif()
  7 +
  8 +include_directories(${GTEST_INCLUDE_DIRS})
  9 +
  10 +add_executable(image_pipeline-test
  11 + main.cpp
  12 + pinhole.cpp
  13 + )
  14 +
  15 +target_link_libraries(image_pipeline-test
  16 + image_pipeline
  17 + ${OpenCV_LIBS}
  18 + ${GTEST_LIBRARIES}
  19 + )
  20 +
  21 +add_test(image_pipeline-test ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/image_pipeline-test)
7 test/main.cpp
... ... @@ -0,0 +1,7 @@
  1 +#include <gtest/gtest.h>
  2 +
  3 +int main(int argc, char** argv)
  4 +{
  5 + ::testing::InitGoogleTest(&argc, argv);
  6 + return RUN_ALL_TESTS();
  7 +}
8 test/pinhole.cpp
... ... @@ -0,0 +1,8 @@
  1 +#include <gtest/gtest.h>
  2 +#include <image_pipeline/image_pipeline.hpp>
  3 +
  4 +TEST(pinhole, Serialize)
  5 +{
  6 + std::cout << "Hello"<<std::endl;
  7 + EXPECT_TRUE(true);
  8 +}

0 comments on commit f5392f5

Please sign in to comment.
Something went wrong with that request. Please try again.