Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Commit

Permalink
Merge pull request #3 from pankhurivanjani/master
Browse files Browse the repository at this point in the history
First release of camViz tool
  • Loading branch information
jmplaza authored Sep 19, 2019
2 parents 7e3cdba + dca02f5 commit 70e7368
Show file tree
Hide file tree
Showing 194 changed files with 35,712 additions and 0 deletions.
94 changes: 94 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
cmake_minimum_required(VERSION 3.5)
project(camviz)
set(CMAKE_BUILD_TYPE Debug)
# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()


if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic -Wunused-parameter)
endif()

SET(rosversion "1" CACHE STRING "Some user-specified option")
message("THIS IS ROS1")
SET( SOURCE_FILES camViz.cpp viewer.cpp)
add_definitions(-DGLADE_DIR="${gladedir}")

find_package(roscpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(image_transport REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(OpenCV REQUIRED)
find_package(cv_bridge REQUIRED)
find_package(yaml-cpp REQUIRED)

find_package(PkgConfig)
pkg_check_modules(GTKMM gtkmm-3.0)

#pkg_check_modules(libglademm libglademm-2.4)

if(roscpp_FOUND)
message("ROS1 found")
add_definitions(-DROS1_H)
add_definitions(-DROS1S_H)
SET(ROS1_H ON)
ELSE()
message("ROS1 not found")
SET(ROS1_H OFF)
SET(ROS1S_H OFF)
endif()
SET( LIBS_EXTRA resourcelocator )

include_directories(${GTKMM_INCLUDE_DIRS}
${resourcelocator_INCLUDE_DIRS}
# ${libglademm_INCLUDE_DIRS}
# ${gtkglextmm_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS}
)

include_directories(${roscpp_INCLUDE_DIRS} ${image_transport_INCLUDE_DIRS} ${sensor_msgs_INCLUDE_DIRS} )
include_directories(
${std_msgs_INCLUDE_DIRS}
${OpenCV_INCLUDE_DIRS}
${cv_bridge_INCLUDE_DIRS}
#${libglademm_INCLUDE_DIRS}
${resourcelocator_INCLUDE_DIRS})

link_directories(
${resourcelocator_LIBRARY_DIRS}
${GTKMM_LIBRARY_DIRS}
${resourcelocator_LIBRARY_DIRS}

)

add_executable (camViz ${SOURCE_FILES})

target_link_libraries(camViz
${roscpp_LIBRARIES}
${std_msgs_LIBRARIES}
${image_transport_LIBRARIES}
${OpenCV_LIBRARIES}
${cv_bridge_LIBRARIES}
${sensor_msgs_LIBRARIES}
${YAML_CPP_LIBRARIES})

TARGET_LINK_LIBRARIES(camViz
${GTKMM_LIBRARIES}
# ${libglademm_LIBRARIES}
${ZLIB_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
${resourcelocator_LIBRARIES}
${catkin_LIBRARIES}
${GLOG_LIBRARIES}

)
install(TARGETS camViz
DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/
COMPONENT camviz
)


INSTALL (FILES ${CMAKE_CURRENT_SOURCE_DIR}/camViz.glade DESTINATION ${CMAKE_INSTALL_PREFIX}/share/jderobot/glade COMPONENT camviz)
INSTALL (FILES ${CMAKE_CURRENT_SOURCE_DIR}/camViz.yml DESTINATION ${CMAKE_INSTALL_PREFIX}/share/jderobot/conf COMPONENT camviz)
1 change: 1 addition & 0 deletions build/.built_by
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
colcon
Empty file added build/COLCON_IGNORE
Empty file.
40 changes: 40 additions & 0 deletions build/camviz/camViz.glade
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--*- mode: xml -*-->
<interface>
<object class="GtkWindow" id="mainwindow">
<property name="visible">True</property>
<property name="title" translatable="yes">CamViz</property>
<child>
<object class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">1</property>
<child>
<object class="GtkLabel" id="fpslabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">0 fps</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkImage" id="image">
<property name="visible">True</property>
<property name="xalign">0.68999999761581421</property>
<property name="stock">gtk-missing-image</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
</object>
</child>
</object>
</interface>
7 changes: 7 additions & 0 deletions build/camviz/camViz.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Server: 1 # Deactivate, ROS , ROS2
Proxy: "cameraA:tcp -h localhost -p 9999"
Format: RGB8
Topic: "/usb_cam/image_raw"
Name: cameraA
Fps: 30
NodeName: camViz
45 changes: 45 additions & 0 deletions camViz.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include <iostream>
#include <chrono>
#include </opt/jderobot/include/jderobot/visionlib/colorspaces/colorspacesmm.h>
#include "viewer.h"
#include "comm/getCameraClientdef.hpp"
#include </opt/jderobot/include/jderobot/types/image.h>
#include <yaml-cpp/yaml.h>


using namespace std;

int main(int argc, char** argv){

camViz::Viewer viewer;


std::string config_file_;
config_file_.assign(argv[1]);

YAML::Node config = YAML::LoadFile(config_file_);
int server = config["Server"].as<int>();

std::string topic = config["Topic"].as<std::string>();
int fps = config["Fps"].as<int>();
std::string nodeName = config["Name"].as<std::string>();


// ***********Get from camera-interface*************
camViz::CameraClient* camRGB;

camRGB = camViz::getCameraClient(argc,argv,server,topic,nodeName);

//////****************View in GUI******************************
JdeRobotTypes::Image rgb;
std::cout << viewer.isVisible();

while(viewer.isVisible()){
rgb = camRGB->getImage();
viewer.display(rgb.data);
viewer.displayFrameRate(1);

}

return 0;
}
40 changes: 40 additions & 0 deletions camViz.glade
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--*- mode: xml -*-->
<interface>
<object class="GtkWindow" id="mainwindow">
<property name="visible">True</property>
<property name="title" translatable="yes">CamViz</property>
<child>
<object class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">1</property>
<child>
<object class="GtkLabel" id="fpslabel">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">0 fps</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_FILL</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<object class="GtkImage" id="image">
<property name="visible">True</property>
<property name="xalign">0.68999999761581421</property>
<property name="stock">gtk-missing-image</property>
</object>
<packing>
<property name="x_options">GTK_FILL</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
</object>
</child>
</object>
</interface>
7 changes: 7 additions & 0 deletions camViz.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Server: 1 # Deactivate, ROS , ROS2
Proxy: "cameraA:tcp -h localhost -p 9999"
Format: RGB8
Topic: "/usb_cam/image_raw"
Name: cameraA
Fps: 30
NodeName: camViz
16 changes: 16 additions & 0 deletions comm/CameraClient.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once
#include <iostream>
#include </opt/jderobot/include/jderobot/types/image.h>

namespace camViz {
class CameraClient {
public:
virtual JdeRobotTypes::Image getImage() = 0;
virtual int getRefreshRate() = 0;
bool on = false;
protected:
JdeRobotTypes::Image image;
int refreshRate;
};
}

8 changes: 8 additions & 0 deletions comm/getCameraClient.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include </opt/jderobot/include/jderobot/types/image.h>

#include "CameraClient.hpp"

namespace camViz {
CameraClient* getCameraClient(int argc, char** argv, int server, std::string topic,std::string nodeName);

}
52 changes: 52 additions & 0 deletions comm/getCameraClientdef.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include <iostream>
#include "sstream"
#include <chrono>
#include <memory>

#include "mainsub.hpp"
#include "getCameraClient.hpp"


namespace camViz{

CameraClient*
getCameraClient(int argc, char** argv, int server, std::string topic,std::string nodeName){
CameraClient* client = NULL;
switch (server){
case 1:
{
#ifdef ROS1S_H
std::cout << "Receiving ROS1 messages" << std::endl;

ListenerCamera* lc;
lc = new ListenerCamera(0, nullptr, nodeName, topic);
lc->start();

client = (camViz::CameraClient*) lc;
//cv::destroyWindow("view");

#else
throw "ERROR: ROS1 is not available";
#endif
break;
}
case 2:
{
std::cout << "This version supports only ROS1 messages" << std::endl;

break;
}
default:
{
printf("Select right distro of ROS");
break;
}

}

return client;


}

}
11 changes: 11 additions & 0 deletions comm/mainsub.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifdef ROS1S_H
#include "ros/ros.h"
#include "std_msgs/String.h"
#include <image_transport/image_transport.h>
#include <opencv2/highgui/highgui.hpp>
#include <cv_bridge/cv_bridge.h>
#include "ros/listenercameraros.hpp"

#endif


Loading

0 comments on commit 70e7368

Please sign in to comment.