diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..03f397c --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..909aa9d --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/robomaster_cv.iml b/.idea/robomaster_cv.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/robomaster_cv.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..62ba360 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..43c3a3c --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "cmake.sourceDirectory": "/Users/aravrawat/Desktop/UT-RoboMasters/robomaster_cv/src/arav_package" +} \ No newline at end of file diff --git a/grayscale_image.jpg b/grayscale_image.jpg new file mode 100644 index 0000000..3535c8f Binary files /dev/null and b/grayscale_image.jpg differ diff --git a/image.jpg b/image.jpg new file mode 100644 index 0000000..3705464 Binary files /dev/null and b/image.jpg differ diff --git a/original_image.jpg b/original_image.jpg new file mode 100644 index 0000000..121c013 Binary files /dev/null and b/original_image.jpg differ diff --git a/src/arav_package/CMakeLists.txt b/src/arav_package/CMakeLists.txt new file mode 100644 index 0000000..62a2362 --- /dev/null +++ b/src/arav_package/CMakeLists.txt @@ -0,0 +1,42 @@ +cmake_minimum_required(VERSION 3.8) +project(arav_package) + +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wall -Wextra -Wpedantic) +endif() + +# find dependencies +find_package(ament_cmake REQUIRED) +find_package(rclcpp REQUIRED) +find_package(std_msgs REQUIRED) +find_package(sensor_msgs REQUIRED) +find_package(cv_bridge REQUIRED) +find_package(OpenCV REQUIRED) +# uncomment the following section in order to fill in +# further dependencies manually. +# find_package( REQUIRED) + +add_executable(arav_node src/arav_node.cpp) +ament_target_dependencies(arav_node rclcpp sensor_msgs cv_bridge OpenCV) +target_include_directories(arav_node PUBLIC + $ + $) +target_compile_features(arav_node PUBLIC c_std_99 cxx_std_17) # Require C99 and C++17 + + +install(TARGETS arav_node + DESTINATION lib/${PROJECT_NAME}) + +if(BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + # the following line skips the linter which checks for copyrights + # comment the line when a copyright and license is added to all source files + set(ament_cmake_copyright_FOUND TRUE) + # the following line skips cpplint (only works in a git repo) + # comment the line when this package is in a git repo and when + # a copyright and license is added to all source files + set(ament_cmake_cpplint_FOUND TRUE) + ament_lint_auto_find_test_dependencies() +endif() + +ament_package() \ No newline at end of file diff --git a/src/arav_package/package.xml b/src/arav_package/package.xml new file mode 100644 index 0000000..b4c627e --- /dev/null +++ b/src/arav_package/package.xml @@ -0,0 +1,25 @@ + + + + arav_package + 0.0.0 + TODO: Package description + admin + TODO: License declaration + + ament_cmake + + ament_lint_auto + ament_lint_common + + rclcpp + std_msgs + sensor_msgs + cv_bridge + OpenCV + + + + ament_cmake + + \ No newline at end of file diff --git a/src/arav_package/src/arav_node.cpp b/src/arav_package/src/arav_node.cpp new file mode 100644 index 0000000..2a9e23c --- /dev/null +++ b/src/arav_package/src/arav_node.cpp @@ -0,0 +1,44 @@ +#include +#include +#include +#include +#include + +using std::placeholders::_1; + +class AravNode : public rclcpp::Node { +public: + AravNode() : Node("AravNode") { + printf("hello world arav_package package\n"); + subscription_ = this->create_subscription( + "image_raw", 10, std::bind(&AravNode::topic_callback, this, _1)); + } + +private: + void topic_callback(const sensor_msgs::msg::Image::SharedPtr msg) const + { + cv_bridge::CvImagePtr cv_ptr; + cv_ptr = cv_bridge::toCvCopy(msg, sensor_msgs::image_encodings::BGR8); + cv::Mat cv_image = cv_ptr->image; + + cv::Mat gray_image; + cv::cvtColor(cv_image, gray_image, cv::COLOR_BGR2GRAY); + cv::imwrite("original_image.jpg", cv_image); + cv::imwrite("grayscale_image.jpg", gray_image); + + } + + rclcpp::Subscription::SharedPtr subscription_; +}; + +int main(int argc, char ** argv) +{ + (void) argc; + (void) argv; + + rclcpp::init(argc, argv); + rclcpp::spin(std::make_shared()); + rclcpp::shutdown(); + + return 0; +}