diff --git a/CMakeLists.txt b/CMakeLists.txt
index caa9075..c8a6b5b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,46 +1,47 @@
cmake_minimum_required (VERSION 2.8)
project(AutoDrive)
set (OUTPUT_NAME AutoDrive)
-
-#add_subdirectory(src/StreamDecoder/HDFDecoder)
-#add_subdirectory(src/StreamDecoder/ProtobufDeserializer)
+add_definitions(-std=c++11)
+SET(CAF_COMPILE_FLAGS "-lcaf_io -lcaf_core")
+add_definitions(${CAF_COMPILE_FLAGS})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
add_subdirectory(src/ScenarioAnalysation)
add_subdirectory(src/ObjectDetection)
-add_subdirectory(src/caf)
-
-#add_subdirectory(src/StreamDecoder/DecompressionExample)
-
-#add_subdirectory(src/StreamDecoder/FrameSelector)
-
+add_subdirectory(src/CarCommunication)
add_subdirectory(src/StreamDecoder)
-
-
+file(GLOB_RECURSE sourcesc "./src/*.cc")
file(GLOB_RECURSE sources "./src/*.cpp")
file(GLOB_RECURSE headers "./src/*.h")
+#protobuf
+include(FindProtobuf)
+find_package(Protobuf REQUIRED)
+include_directories(${PROTOBUF_INCLUDE_DIR})
+
#opencv
-#find_package( OpenCV )
-#if(OpenCV_FOUND)
-#include_directories( ${OpenCV_INCLUDE_DIRS} )
-#set(LINK_LIBS ${LINK_LIBS} ${OpenCV_LIBS})
-#else(OpenCV_FOUND)
-#message(SEND_ERROR "OpenCV not found")
-#endif(OpenCV_FOUND)
+find_package( OpenCV )
+if(OpenCV_FOUND)
+ include_directories( ${OpenCV_INCLUDE_DIRS} )
+ set(LINK_LIBS ${LINK_LIBS} ${OpenCV_LIBS})
+else(OpenCV_FOUND)
+ message(SEND_ERROR "OpenCV not found")
+endif(OpenCV_FOUND)
#hdf5
-#find_package (HDF5)
-#if(HDF5_FOUND)
-#set(LINK_LIBS ${LINK_LIBS} ${HDF5_C_STATIC_LIBRARY} ${HDF5_C_LIBRARIES})
-#include_directories(${HDF5_INCLUDE_DIR})
-#else(HDF5_FOUND)
-#message(SEND_ERROR "HDF5 was not Found")
-#endif(HDF5_FOUND)
-
-#add_executable(${OUTPUT_NAME} ${sources} ${headers})
-#target_link_libraries(${OUTPUT_NAME} ${LINK_LIBS} -lhdf5_cpp -lhdf5)
-#target_link_libraries(${OUTPUT_NAME} proto ${PROTOBUF_LIBRARY})
-
+find_package (HDF5)
+if(HDF5_FOUND)
+ set(LINK_LIBS ${LINK_LIBS} ${HDF5_C_STATIC_LIBRARY} ${HDF5_C_LIBRARIES})
+ include_directories(${HDF5_INCLUDE_DIR})
+else(HDF5_FOUND)
+ message(SEND_ERROR "HDF5 was not Found")
+endif(HDF5_FOUND)
+
+add_definitions(-D COMBINE)
+
+add_executable(${OUTPUT_NAME} ${sources} ${headers} ${sourcesc})
+target_link_libraries(${OUTPUT_NAME} ${LINK_LIBS} -lhdf5_cpp -lhdf5)
+target_link_libraries(${OUTPUT_NAME} ${PROTOBUF_LIBRARY})
+target_link_libraries(${OUTPUT_NAME} ${PROTOBUF_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} -lcaf_io -lcaf_core)
diff --git a/src/caf/CMakeLists.txt b/src/CarCommunication/CMakeLists.txt
similarity index 88%
rename from src/caf/CMakeLists.txt
rename to src/CarCommunication/CMakeLists.txt
index 963390c..6a5ebe9 100644
--- a/src/caf/CMakeLists.txt
+++ b/src/CarCommunication/CMakeLists.txt
@@ -16,6 +16,6 @@ else(PROTOBUF_FOUND)
message(SEND_ERROR "Protobuff NOT found")
endif(PROTOBUF_FOUND)
-ADD_EXECUTABLE(${OUTPUT_NAME} protobuf_broker.cpp ${PROTO_HEADER} ${PROTO_SRC})
+ADD_EXECUTABLE(${OUTPUT_NAME} protoagent.cpp ${PROTO_HEADER} ${PROTO_SRC})
target_link_libraries(${OUTPUT_NAME} ${PROTOBUF_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} -lcaf_io -lcaf_core)
diff --git a/src/caf/Makefile b/src/CarCommunication/Makefile
similarity index 100%
rename from src/caf/Makefile
rename to src/CarCommunication/Makefile
diff --git a/src/caf/message.pb.cc b/src/CarCommunication/message.pb.cc
similarity index 100%
rename from src/caf/message.pb.cc
rename to src/CarCommunication/message.pb.cc
diff --git a/src/caf/message.pb.h b/src/CarCommunication/message.pb.h
similarity index 100%
rename from src/caf/message.pb.h
rename to src/CarCommunication/message.pb.h
diff --git a/src/caf/message.proto b/src/CarCommunication/message.proto
similarity index 100%
rename from src/caf/message.proto
rename to src/CarCommunication/message.proto
diff --git a/src/caf/pbbroker b/src/CarCommunication/pbbroker
old mode 100755
new mode 100644
similarity index 100%
rename from src/caf/pbbroker
rename to src/CarCommunication/pbbroker
diff --git a/src/caf/protobuf_broker.cpp b/src/CarCommunication/protoagent.cpp
similarity index 99%
rename from src/caf/protobuf_broker.cpp
rename to src/CarCommunication/protoagent.cpp
index 400ffc5..e07193f 100644
--- a/src/caf/protobuf_broker.cpp
+++ b/src/CarCommunication/protoagent.cpp
@@ -23,7 +23,7 @@
// .
//
-#include "protobuf_broker.h"
+#include "protoagent.h"
void ProtoAgent::print_on_exit(const actor& hdl, const std::string& name) {
hdl->attach_functor([=](abstract_actor* ptr, uint32_t reason) {
@@ -211,6 +211,7 @@ void ProtoAgent::startServer (uint16_t port) {
shutdown();
}
+#ifndef COMBINE
int main(int argc, char** argv) {
// Parsing arguments
message_builder{argv + 1, argv + argc}.apply({
@@ -231,3 +232,5 @@ int main(int argc, char** argv) {
}
});
}
+
+#endif
\ No newline at end of file
diff --git a/src/caf/protobuf_broker.h b/src/CarCommunication/protoagent.h
similarity index 93%
rename from src/caf/protobuf_broker.h
rename to src/CarCommunication/protoagent.h
index 98fe182..ac6c71b 100644
--- a/src/caf/protobuf_broker.h
+++ b/src/CarCommunication/protoagent.h
@@ -57,14 +57,14 @@ class ProtoAgent {
* @param port Specified port for communication
* @param hsot Hostname for connection to server
*/
- void startClient (uint16_t port, const string& host);
+ static void startClient (uint16_t port, const string& host);
/**
* starts the server.
*
* @param port Specified port for communication
*/
- void startServer (uint16_t port);
+ static void startServer (uint16_t port);
/**
* utility function to print an exit message with custom name.
@@ -73,7 +73,7 @@ class ProtoAgent {
* @param name Actor name
*/
- void print_on_exit(const actor& hdl, const std::string& name);
+ static void print_on_exit(const actor& hdl, const std::string& name);
/**
diff --git a/src/ObjectDetection/main.cpp b/src/ObjectDetection/main.cpp
index a26cdeb..ac1e92c 100644
--- a/src/ObjectDetection/main.cpp
+++ b/src/ObjectDetection/main.cpp
@@ -20,7 +20,9 @@
// License along with this program. If not, see
// .
+#ifndef COMBINE
int main(int argc, const char * argv[]) {
return 0;
}
+#endif
\ No newline at end of file
diff --git a/src/ProcessControl/controller.cpp b/src/ProcessControl/controller.cpp
index 9d43da2..6fdc234 100644
--- a/src/ProcessControl/controller.cpp
+++ b/src/ProcessControl/controller.cpp
@@ -34,7 +34,7 @@
#include "../ScenarioAnalysation/humans_in_front_of_bus_scenario.h"
#include "../ScenarioAnalysation/analyser.h"
#include "controller.h"
-
+#include "../CarCommunication/protoagent.h"
//define keys
const int KEY_ESC = 27;
@@ -54,7 +54,7 @@ void Controller::PlayAsVideo(std::string videofile) {
}
}
-void Controller::AnalyseVideo(std::string videofile) {
+void Controller::AnalyseVideo(std::string videofile, uint16_t port, std::string host) {
ImageView image_view;
FrameSelectorFactory frame_selector_factory(videofile);
FrameSelector* pipeline = frame_selector_factory.GetFrameSelector();
@@ -95,6 +95,14 @@ void Controller::AnalyseVideo(std::string videofile) {
// for demo: show information about scenario in current frame
std::cout << "Current detected scenario: " << scenario->GetScenarioInformation() << " in frame: " << i << std::endl;
+ #ifdef COMBINE
+ //Notifying other car
+ if(port!=0)
+ {
+ std::cout << "Informing other car" << std::endl;
+ ProtoAgent::startClient(port,host);
+ }
+ #endif
}
int key = cvWaitKey(10);
diff --git a/src/ProcessControl/controller.h b/src/ProcessControl/controller.h
index 7619d70..568b4a6 100644
--- a/src/ProcessControl/controller.h
+++ b/src/ProcessControl/controller.h
@@ -45,7 +45,7 @@ class Controller{
*
*@param videofile path to the video file
*/
- void AnalyseVideo(std::string videofile);
+ void AnalyseVideo(std::string videofile, uint16_t port = 0, std::string host = "");
/**
* Saves all images as jepg to disc
diff --git a/src/ProcessControl/main.cpp b/src/ProcessControl/main.cpp
new file mode 100644
index 0000000..c15d734
--- /dev/null
+++ b/src/ProcessControl/main.cpp
@@ -0,0 +1,81 @@
+//
+// Projectname: amos-ss16-proj5
+//
+// Copyright (c) 2016 de.fau.cs.osr.amos2016.gruppe5
+//
+// This file is part of the AMOS Project 2016 @ FAU
+// (Friedrich-Alexander University Erlangen-Nürnberg)
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public
+// License along with this program. If not, see
+// .
+
+
+/*
+* This is the global main for our project
+*/
+#include "caf/all.hpp"
+#include "caf/io/all.hpp"
+
+#include
+#include "controller.h"
+#include "../CarCommunication/protoagent.h"
+using namespace std;
+
+static bool
+str_to_uint16(const char *str, uint16_t *res)
+{
+ char *end;
+ errno = 0;
+ intmax_t val = strtoimax(str, &end, 10);
+ if (errno == ERANGE || val < 0 || val > UINT16_MAX || end == str || *end != '\0')
+ return false;
+ *res = (uint16_t) val;
+ return true;
+}
+
+int main(int argc, const char * argv[]) {
+
+ if(argc == 2){
+ uint16_t port;
+ if(str_to_uint16(argv[1],&port))
+ {
+ ProtoAgent::startServer(port);
+ }
+ else
+ {
+ cerr << "Could not read port" << endl;
+ }
+ }else if(argc = 4)
+ {
+ uint16_t port;
+ if(str_to_uint16(argv[1],&port))
+ {
+ Controller controller;
+ controller.AnalyseVideo(argv[3],port,argv[2]);
+ }
+ else
+ {
+ cerr << "Could not read port" << endl;
+ }
+
+ }
+ else
+ {
+ cerr << "Usage: " << " PORT (SERVER_IP_ADRESS FULL_PATH_TO_HDF5_FILE)" << endl;
+ return -1;
+ }
+
+
+ return 0;
+}
diff --git a/src/ScenarioAnalysation/main.cpp b/src/ScenarioAnalysation/main.cpp
index abd9d0b..8cbd914 100644
--- a/src/ScenarioAnalysation/main.cpp
+++ b/src/ScenarioAnalysation/main.cpp
@@ -36,7 +36,7 @@
using namespace std;
-
+#ifndef COMBINE
int main(int argc, const char* argv[]) {
if (argc > 1 ){
@@ -105,3 +105,5 @@ int main(int argc, const char* argv[]) {
return 0;
}
+
+#endif
\ No newline at end of file
diff --git a/src/StreamDecoder/main.cpp b/src/StreamDecoder/main.cpp
index f63f03e..795c8ec 100644
--- a/src/StreamDecoder/main.cpp
+++ b/src/StreamDecoder/main.cpp
@@ -31,7 +31,7 @@
using namespace std;
-
+#ifndef COMBINE
int main(int argc, const char* argv[]) {
if (argc > 3 || argc == 1){
@@ -65,3 +65,5 @@ int main(int argc, const char* argv[]) {
return 0;
}
+
+#endif
\ No newline at end of file