Skip to content

Commit

Permalink
new recorder
Browse files Browse the repository at this point in the history
  • Loading branch information
Somliga committed Jun 11, 2018
1 parent 189b622 commit ca9be7f
Show file tree
Hide file tree
Showing 13 changed files with 16,519 additions and 1,524 deletions.
29 changes: 5 additions & 24 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@

cmake_minimum_required(VERSION 3.2)

project(cfsd18-perception-detectcone)
project(cfsd18-perception-imagerecorder)

################################################################################
# Defining the relevant versions of OpenDLV Standard Message Set and libcluon.
set(OPENDLV_STANDARD_MESSAGE_SET opendlv-standard-message-set-v0.9.1.odvd)
set(CLUON_COMPLETE cluon-complete-v0.0.77.hpp)
set(CLUON_COMPLETE cluon-complete-v0.0.99.hpp)

################################################################################
# This project requires C++14 or newer.
Expand Down Expand Up @@ -84,11 +84,6 @@ find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})


################################################################################
# Eigen
find_package(Eigen3 REQUIRED NO_MODULE)
include_directories(${Eigen3_INCLUDE_DIRS})

###############################################################################
# OpenMP
OPTION (USE_OpenMP "Use OpenMP" ON)
Expand All @@ -100,15 +95,6 @@ IF(USE_OpenMP)
ENDIF()
ENDIF()

###############################################################################
#TinyDnn
find_package(TinyDNN REQUIRED)

###############################################################################
#TBB
#find_package(TBB REQUIRED)
#include_directories(${TBB_INCLUDE_DIRS})
#add_definitions(${TBB_DEFINITIONS})

SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")

Expand All @@ -119,21 +105,16 @@ include_directories(SYSTEM ${LIBRT_INCLUDE_DIR})
# Link libs
#set(LIBRARIES Threads::Threads opencv_core opencv_imgcodecs opencv_features2d opencv_imgproc opencv_highgui opencv_calib3d rt libgio-2.0)

include_directories(SYSTEM /usr/include)
include_directories(SYSTEM /usr/local/include)
link_directories(SYSTEM /usr/lib) #Access g2o
link_directories(SYSTEM /usr/local/lib) #Access g2o

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)

add_library(${PROJECT_NAME}-core STATIC ${CMAKE_CURRENT_SOURCE_DIR}/src/detectcone.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/cone.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/point.cpp ${CMAKE_BINARY_DIR}/opendlv-standard-message-set.cpp)
add_library(${PROJECT_NAME}-core ${CMAKE_BINARY_DIR}/opendlv-standard-message-set.cpp)

# Add custom libs h
set(LIBRARIES ${LIBRARIES} Threads::Threads ${OpenCV_LIBS} ${Eigen3_LIBS} ${TinyDNN_LIBS} rt)
set(LIBRARIES ${LIBRARIES} Threads::Threads ${OpenCV_LIBS} rt)

MESSAGE(STATUS "heej")
MESSAGE(STATUS ${LIBRARIES})
#${TBB_LIBRARIES}

################################################################################
# Create executable.
Expand All @@ -143,7 +124,7 @@ target_link_libraries(${PROJECT_NAME} ${PROJECT_NAME}-core ${LIBRARIES}) #Links
################################################################################
# Enable unit testing.
enable_testing()
add_executable(${PROJECT_NAME}-runner ${CMAKE_CURRENT_SOURCE_DIR}/test/tests-cfsd18-perception-detectcone.cpp)
add_executable(${PROJECT_NAME}-runner ${CMAKE_CURRENT_SOURCE_DIR}/test/tests-cfsd18-perception-imagerecorder.cpp)
target_link_libraries(${PROJECT_NAME}-runner ${LIBRARIES} ${PROJECT_NAME}-core)
add_test(NAME ${PROJECT_NAME}-runner COMMAND ${PROJECT_NAME}-runner)

Expand Down
26 changes: 4 additions & 22 deletions Dockerfile.amd64
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,6 @@ RUN apk update && \

WORKDIR /tmp

#RUN git clone https://github.com/justusc/FindTBB.git && \
# cp FindTBB/FindTBB.cmake /usr/share/cmake/Modules/ && \
# cd FindTBB && \
# ./test.sh

RUN git clone https://github.com/tiny-dnn/tiny-dnn.git && \
mkdir -p tiny-dnn/build && \
# cp sources/config.h tiny-dnn/tiny_dnn/config.h && \
cd tiny-dnn/build && \
cmake .. && \
make install

RUN git clone https://github.com/eigenteam/eigen-git-mirror.git && \
mkdir -p eigen-git-mirror/build && \
cd eigen-git-mirror/build && \
cmake .. && \
make install
RUN echo "@testing http://nl.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
RUN apk update && \
apk --no-cache add \
Expand All @@ -59,18 +42,17 @@ ADD . /opt/sources
WORKDIR /opt/sources
RUN mkdir -p build && \
cd build && \
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/tmp/cfsd18-perception-detectcone-dest .. && \
make -j3 && make test && make install && upx -9 /tmp/cfsd18-perception-detectcone-dest/bin/cfsd18-perception-detectcone
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/tmp/cfsd18-perception-imagerecorder-dest .. && \
make -j3 && make test && make install && upx -9 /tmp/cfsd18-perception-imagerecorder-dest/bin/cfsd18-perception-imagerecorder

# Part to deploy opendlv-perception-vision-orbslam2
FROM alpine:edge
MAINTAINER Christian Berger "[email protected]"

#Start microservice
WORKDIR /usr/bin
COPY --from=builder /usr/local/include/ /usr/include/
COPY --from=builder /usr/local/lib/ /usr/lib/
COPY --from=builder /usr/lib/ /usr/lib/
COPY --from=builder /tmp/cfsd18-perception-detectcone-dest/bin/cfsd18-perception-detectcone .
COPY --from=builder /tmp/cfsd18-perception-imagerecorder-dest/bin/cfsd18-perception-imagerecorder .
RUN apk update && apk add glib
CMD ["/usr/bin/cfsd18-perception-detectcone"]
CMD ["/usr/bin/cfsd18-perception-imagerecorder"]
143 changes: 0 additions & 143 deletions include/detectcone.hpp

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,26 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <memory>
#include <vector>
#include <cmath>
#include <thread>
#include <cstdint>
#include <tuple>
#include <utility>
#include <string>
#include <sstream>

#include "cluon-complete.hpp"
#include "opendlv-standard-message-set.hpp"

#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

#include "detectcone.hpp"

int32_t main(int32_t argc, char **argv) {
int32_t retCode{0};
Expand Down Expand Up @@ -44,7 +62,6 @@ int32_t main(int32_t argc, char **argv) {
// od4.dataTrigger(opendlv::logic::perception::ObjectDistance::ID(),envelopeRecieved);

// // Just sleep as this microservice is data driven.
// using namespace std::literals::chrono_literals;
// while (od4.isRunning()) {
// std::this_thread::sleep_for(1s);
// std::chrono::system_clock::time_point tp;
Expand All @@ -53,6 +70,7 @@ int32_t main(int32_t argc, char **argv) {



using namespace std::literals::chrono_literals;
const uint32_t WIDTH{static_cast<uint32_t>(std::stoi(commandlineArguments["width"]))};
const uint32_t HEIGHT{static_cast<uint32_t>(std::stoi(commandlineArguments["height"]))};
const uint32_t BPP{static_cast<uint32_t>(std::stoi(commandlineArguments["bpp"]))};
Expand All @@ -64,16 +82,20 @@ int32_t main(int32_t argc, char **argv) {
const uint32_t SIZE{WIDTH * HEIGHT * BPP/8};
const std::string NAME{(commandlineArguments["name"].size() != 0) ? commandlineArguments["name"] : "/cam0"};
const uint32_t ID{(commandlineArguments["id"].size() != 0) ? static_cast<uint32_t>(std::stoi(commandlineArguments["id"])) : 0};
const bool VERBOSE{commandlineArguments.count("verbose") != 0};
//const bool VERBOSE{commandlineArguments.count("verbose") != 0};

(void)ID;
(void)SIZE;
std::cout << "Making slammer" << VERBOSE << std::endl;
DetectCone detectcone(commandlineArguments, od4);

std::string filepathTimestamp;
filepathTimestamp = "/opt/timestamp/timestamps.txt";
std::ofstream f;
f.open(filepathTimestamp.c_str());

// Interface to a running OpenDaVINCI session (ignoring any incoming Envelopes).
// cluon::OD4Session od4{static_cast<uint16_t>(std::stoi(commandlineArguments["cid"]))};
size_t frameCounter = 0;

std::string imgPath = "/opt/images/";
std::unique_ptr<cluon::SharedMemory> sharedMemory(new cluon::SharedMemory{NAME});
if (sharedMemory && sharedMemory->valid()) {
std::clog << argv[0] << ": Found shared memory '" << sharedMemory->name() << "' (" << sharedMemory->size() << " bytes)." << std::endl;
Expand All @@ -98,13 +120,20 @@ int32_t main(int32_t argc, char **argv) {
image->imageData = sharedMemory->data();
image->imageDataOrigin = image->imageData;
cv::Mat img = cv::cvarrToMat(image);

cluon::data::TimeStamp imgTimestamp = cluon::time::now();

int64_t ts = cluon::time::toMicroseconds(imgTimestamp);

f << std::setprecision(19) << ts << std::endl;
std::string saveString = imgPath + std::to_string(frameCounter) + ".png";
cv::imwrite( saveString, img);

std::cout << "Saved image: " << frameCounter << std::endl;
sharedMemory->unlock();
cv::waitKey(1);
detectcone.forwardDetectionORB(img);
frameCounter++;
}

f.close();
cvReleaseImageHeader(&image);
}
else {
Expand All @@ -113,6 +142,8 @@ int32_t main(int32_t argc, char **argv) {
}

}


return retCode;
}

Expand Down
Loading

0 comments on commit ca9be7f

Please sign in to comment.