Skip to content

Commit

Permalink
Combined CarCommunication with the framedetection
Browse files Browse the repository at this point in the history
added new main to ProcessControl
renamed caf dir to CarCommunication
integrated communication into the Control class
  • Loading branch information
JoHeinrich committed Jun 21, 2016
1 parent d0f044e commit 751075b
Show file tree
Hide file tree
Showing 13 changed files with 98 additions and 70 deletions.
34 changes: 1 addition & 33 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,9 @@ 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/CarCommunication)
add_subdirectory(src/StreamDecoder)



file(GLOB_RECURSE sources0 "./src/ScenarioAnalysation/*.cpp")
file(GLOB_RECURSE headers0 "./src/ScenarioAnalysation/*.h")

file(GLOB_RECURSE sources1 "./src/ObjectDetection/*.cpp")
file(GLOB_RECURSE headers1 "./src/ObjectDetection/*.h")

file(GLOB_RECURSE sources2 "./src/StreamDecoder/*.cpp")
file(GLOB_RECURSE sourcesc2 "./src/StreamDecoder/*.cc")
file(GLOB_RECURSE headers2 "./src/StreamDecoder/*.h")

file(GLOB_RECURSE sources3 "./src/caf/*.cpp")
file(GLOB_RECURSE sourcesc3 "./src/caf/*.cc")
file(GLOB_RECURSE headers3 "./src/caf/*.h")

LIST(APPEND sources ${sources0} ${sources1} ${sources2} ${sourcesc2} ${sources3} ${sourcesc3}
#src/ObjectDetection/element.cpp
#src/ObjectDetection/frame_detection_data.cpp
#src/StreamDecoder/image.cpp
#src/StreamDecoder/image_view.cpp

)

LIST(APPEND headers ${headers0} ${headers1} ${header2} ${headers3}
#src/ObjectDetection/element.h
#src/ObjectDetection/frame_detection_data.h
#src/StreamDecoder/image.h
#src/StreamDecoder/image_view.h


)
file(GLOB_RECURSE sourcesc "./src/*.cc")
file(GLOB_RECURSE sources "./src/*.cpp")
file(GLOB_RECURSE headers "./src/*.h")
Expand Down
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
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
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;
}
29 changes: 0 additions & 29 deletions src/main.cpp

This file was deleted.

0 comments on commit 751075b

Please sign in to comment.