Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
Merge pull request #83 from vinay0410/packaging
Browse files Browse the repository at this point in the history
Packaging
  • Loading branch information
chanfr committed Aug 7, 2018
2 parents b129726 + 98a87dc commit e8bd920
Show file tree
Hide file tree
Showing 16 changed files with 294 additions and 41 deletions.
62 changes: 62 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
language: cpp

# blacklist
branches:
except:
- master

# whitelist
branches:
only:
- travis-test

os:
- linux
- osx

sudo: required
dist: xenial

compiler:
- gcc
- clang

cache:
pip: true
directories:
- $HOME/opencv/

before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install boost rapidjson glog yaml-cpp qt ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PATH="/usr/local/opt/qt/bin:$PATH" ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install opencv ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then wget https://www.python.org/ftp/python/2.7.15/python-2.7.15-macosx10.6.pkg ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then sudo installer -pkg python-2.7.15-macosx10.6.pkg -target / ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}" ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt install -y rapidjson-dev ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt install -y libboost-dev libboost-filesystem-dev libboost-system-dev libboost-program-options-dev ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt install -y libgoogle-glog-dev libyaml-cpp-dev qt5-default libqt5svg5-dev libqt5opengl5-dev ; fi
- sudo pip install numpy
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./install_opencv.sh ; fi

before_script:
- cd DeepLearningSuite
- mkdir build
- cd build
- cmake ..

script: make -j4


after_success:
- bash ../package.sh
- ls -lh out/* # Assuming you have some files in out/ that you would like to upload
- wget -c https://github.com/probonopd/uploadtool/raw/master/upload.sh
- bash upload.sh out/*


branches:
except:
- # Do not build tags that we create when we upload to GitHub Releases
- /^(?i:continuous)$/
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
#include <boost/algorithm/string/erase.hpp>
#include <glog/logging.h>

#if CV_MAJOR_VERSION == 2

namespace cv {
#define COLOR_RGB2BGR CV_RGB2BGR
}


#endif


RecorderReader::RecorderReader(const std::string &colorImagesPath, const std::string &depthImagesPath):DatasetReader(true), colorPath(colorImagesPath), depthPath(depthImagesPath) {
Expand Down Expand Up @@ -89,7 +97,7 @@ bool RecorderReader::getNextSample(Sample &sample) {

cv::Mat colorImage= cv::imread(getPathByIndex(this->colorPath,closest(colorIndexes,indexValue),this->syncedData?"-rgb":""));
// if (!this->syncedData)
cv::cvtColor(colorImage,colorImage,CV_RGB2BGR);
cv::cvtColor(colorImage,colorImage,cv::COLOR_RGB2BGR);

sample.setColorImage(colorImage);
sample.setDepthImage(getPathByIndex(this->depthPath,indexValue,this->syncedData?"-depth":""));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
#include <Utils/JsonHelper.h>
#include <Utils/DepthUtils.h>

#if CV_MAJOR_VERSION == 2

namespace cv {
#define IMREAD_ANYDEPTH CV_LOAD_IMAGE_ANYDEPTH

}
#endif


PrincetonDatasetReader::PrincetonDatasetReader(const std::string &path, const std::string &classNamesFile,const bool imagesRequired):DatasetReader(imagesRequired) {
this->classNamesFile=classNamesFile;
Expand Down Expand Up @@ -49,7 +57,7 @@ bool PrincetonDatasetReader::appendDataset(const std::string &datasetPath, const
ssDepth << "d-" << depthTimestamp[i] << "-" << depthFrameID[i] << ".png";
std::string depthImagePath = PathHelper::concatPaths(datasetPath, "depth");
depthImagePath = PathHelper::concatPaths(depthImagePath, ssDepth.str());
cv::Mat depthImage = cv::imread(depthImagePath, CV_LOAD_IMAGE_ANYDEPTH);
cv::Mat depthImage = cv::imread(depthImagePath, cv::IMREAD_ANYDEPTH);
cv::Mat ownDepthImage;
DepthUtils::mat16_to_ownFormat(depthImage,ownDepthImage);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,17 @@
#include <Utils/DepthUtils.h>
#include <glog/logging.h>


#if CV_MAJOR_VERSION == 2

namespace cv {

#define IMREAD_ANYDEPTH CV_LOAD_IMAGE_ANYDEPTH

}

#endif

SpinelloDatasetReader::SpinelloDatasetReader(const std::string &path,const std::string& classNamesFile,const bool imagesRequired):DatasetReader(imagesRequired) {
this->classNamesFile=classNamesFile;
appendDataset(path);
Expand Down Expand Up @@ -60,7 +71,7 @@ bool SpinelloDatasetReader::appendDataset(const std::string &datasetPath, const
std::string colorImagePath=datasetPath + "/" + "rgb" + "/" + imageID + ".ppm";
std::string depthImagePath=datasetPath + "/" + "depth" + "/" + imageID + ".pgm";
cv::Mat colorImage= cv::imread(colorImagePath);
cv::Mat depthImage= cv::imread(depthImagePath, CV_LOAD_IMAGE_ANYDEPTH);
cv::Mat depthImage= cv::imread(depthImagePath, cv::IMREAD_ANYDEPTH);

cv::Mat ownDepthImage;
//DepthUtils::mat16_to_ownFormat(depthImage,ownDepthImage);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef SAMPLERGENERATOR_MASSINFERENCER_H
#define SAMPLERGENERATOR_MASSINFERENCER_H

#include <DatasetConverters/readers/DatasetReader.h>
#include <FrameworkEvaluator/FrameworkInferencer.h>

class MassInferencer {
public:
MassBatchInferencer(DatasetReaderPtr reader, FrameworkInferencerPtr inferencer, const std::string& resultsPath, double* confidence_threshold = NULL, bool debug=true);
MassBatchInferencer(DatasetReaderPtr reader, FrameworkInferencerPtr inferencer, const std::string& resultsPath, bool debug=true);
MassBatchInferencer(DatasetReaderPtr reader, FrameworkInferencerPtr inferencer, const std::string &resultsPath, bool* stopDeployer, double* confidence_threshold = NULL, bool debug=true);
MassBatchInferencer(DatasetReaderPtr reader, FrameworkInferencerPtr inferencer, double* confidence_threshold = NULL, bool debug=true);
MassBatchInferencer(DatasetReaderPtr reader, FrameworkInferencerPtr inferencer, bool debug=true);
void process(int batch_size, bool writeImages, DatasetReaderPtr readerDetection = NULL);

private:
DatasetReaderPtr reader;
FrameworkInferencerPtr inferencer;
std::string resultsPath;
bool debug;
bool saveOutput;
int alreadyProcessed;
bool* stopDeployer = NULL;
double* confidence_threshold = NULL;
double default_confidence_threshold = 0.2;

};



#endif //SAMPLERGENERATOR_MASSINFERENCER_H
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void DetectionsValidator::validate(const cv::Mat& colorImage,const cv::Mat& dept
for (auto it= detections.begin(), end = detections.end(); it != end; ++it){
int idx= (int)std::distance(detections.begin(),it);
cv::Scalar color( 150);
cv::drawContours( mask, detections, idx, color, CV_FILLED, 8);
cv::drawContours( mask, detections, idx, color, -1, 8);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void ContourRegions::drawRegions(cv::Mat &image) {
cv::Scalar color(255);
std::vector<std::vector<cv::Point>> contours;
contours.push_back(it->region);
cv::drawContours(mask, contours, 0, color, CV_FILLED, 8);
cv::drawContours(mask, contours, 0, color, -1, 8);
std::vector<cv::Mat> channels;
cv::split(image, channels);
cv::Mat colorMask(image.size(), CV_8UC1, cv::Scalar(255));
Expand Down
13 changes: 13 additions & 0 deletions DeepLearningSuite/DeepLearningSuiteLib/Regions/Regions.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@
#include <opencv2/opencv.hpp>
#include <boost/shared_ptr.hpp>


#if CV_MAJOR_VERSION == 2

namespace cv { // Fix for different opencv versions

#define RETR_CCOMP CV_RETR_CCOMP
#define CHAIN_APPROX_SIMPLE CV_CHAIN_APPROX_SIMPLE

}

#endif


struct Regions{
Regions(){};
virtual void saveJson(const std::string& outPath)=0;
Expand Down
7 changes: 3 additions & 4 deletions DeepLearningSuite/DeepLearningSuiteLib/Regions/RleRegions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ void RleRegions::drawRegions(cv::Mat &image) {

rleDecode(&(it->region), mask.data , 1);
mask = mask * 255;
cv::rotate(mask, mask, cv::ROTATE_90_CLOCKWISE);
cv::flip(mask, mask, 1);
cv::Mat rotatedMask = mask.t();


cv::Scalar color;
Expand All @@ -98,14 +97,14 @@ void RleRegions::drawRegions(cv::Mat &image) {
color = cv::Scalar(2,166,101);
} else {
color = cv::Scalar((unsigned int)(distribution(generator)*170), (unsigned int)(distribution(generator)*170), (unsigned int)(distribution(generator)*170));
cv::findContours( mask.clone(), contours, CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE, cv::Point(0, 0) );
cv::findContours( rotatedMask.clone(), contours, cv::RETR_CCOMP, cv::CHAIN_APPROX_SIMPLE, cv::Point(0, 0) );

}

cv::Mat colorMask(image.size(), CV_8UC3, color);

cv::Mat output(colorMask.size(), CV_8UC3, cv::Scalar(0));
colorMask.copyTo(output, mask);
colorMask.copyTo(output, rotatedMask);

image = image.mul((( 255 - output )/255 )) + output;
cv::drawContours(image, contours, -1, color, 2, 8);
Expand Down
4 changes: 2 additions & 2 deletions DeepLearningSuite/Deps/numpy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ SET(CMAKE_MODULE_PATH
)


find_package( PythonInterp REQUIRED )
find_package( PythonLibs REQUIRED )
find_package( PythonInterp 2.7.12 REQUIRED )
find_package( PythonLibs 2.7.12 REQUIRED )
find_package( NumPy REQUIRED )

SET(PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS} ${PYTHON_NUMPY_INCLUDE_DIR})
Expand Down
2 changes: 1 addition & 1 deletion DeepLearningSuite/Deps/opencv/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FIND_PACKAGE(OpenCV QUIET)
FIND_PACKAGE(OpenCV)

if(OpenCV_FOUND)
include(CheckIncludeFileCXX)
Expand Down
9 changes: 5 additions & 4 deletions DeepLearningSuite/Deps/qt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ OPTION(ENABLE_QT "Enable Qt support for GUI" ON)
IF(ENABLE_QT)

FIND_PACKAGE(Qt5Core) # Just to print error if Qt isn't found
FIND_PACKAGE(Qt5Widgets QUIET)
FIND_PACKAGE(Qt5Gui QUIET)
FIND_PACKAGE(Qt5Svg QUIET)
FIND_PACKAGE(Qt5OpenGL QUIET)
FIND_PACKAGE(Qt5Widgets)
FIND_PACKAGE(Qt5Gui)
FIND_PACKAGE(Qt5Svg)
FIND_PACKAGE(Qt5OpenGL)

IF (Qt5Widgets_FOUND AND Qt5Core_FOUND AND Qt5Gui_FOUND AND Qt5Svg_FOUND AND Qt5OpenGL_FOUND)

Expand All @@ -26,6 +26,7 @@ IF(ENABLE_QT)
${Qt5OpenGL_LIBRARIES}
)

message(${QT_INCLUDE_DIRS})
SET(QT_FOUND TRUE)
ELSE()

Expand Down
Loading

0 comments on commit e8bd920

Please sign in to comment.