Skip to content

Commit

Permalink
Merge pull request #85 from JoHeinrich/combine
Browse files Browse the repository at this point in the history
Combine
  • Loading branch information
JoHeinrich authored Jun 21, 2016
2 parents ebaa678 + 751075b commit 4c24341
Show file tree
Hide file tree
Showing 15 changed files with 139 additions and 40 deletions.
61 changes: 31 additions & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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)

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// <http://www.gnu.org/licenses/>.
//

#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) {
Expand Down Expand Up @@ -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({
Expand All @@ -231,3 +232,5 @@ int main(int argc, char** argv) {
}
});
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);


/**
Expand Down
2 changes: 2 additions & 0 deletions src/ObjectDetection/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
// License along with this program. If not, see
// <http://www.gnu.org/licenses/>.

#ifndef COMBINE
int main(int argc, const char * argv[]) {

return 0;
}
#endif
12 changes: 10 additions & 2 deletions src/ProcessControl/controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/ProcessControl/controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
81 changes: 81 additions & 0 deletions src/ProcessControl/main.cpp
Original file line number Diff line number Diff line change
@@ -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
// <http://www.gnu.org/licenses/>.


/*
* This is the global main for our project
*/
#include "caf/all.hpp"
#include "caf/io/all.hpp"

#include <iostream>
#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;
}
4 changes: 3 additions & 1 deletion src/ScenarioAnalysation/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

using namespace std;


#ifndef COMBINE
int main(int argc, const char* argv[]) {

if (argc > 1 ){
Expand Down Expand Up @@ -105,3 +105,5 @@ int main(int argc, const char* argv[]) {

return 0;
}

#endif
4 changes: 3 additions & 1 deletion src/StreamDecoder/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

using namespace std;


#ifndef COMBINE
int main(int argc, const char* argv[]) {

if (argc > 3 || argc == 1){
Expand Down Expand Up @@ -65,3 +65,5 @@ int main(int argc, const char* argv[]) {

return 0;
}

#endif

0 comments on commit 4c24341

Please sign in to comment.