Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add matchTemplate nodelet #68

Open
wants to merge 16 commits into
base: indigo
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 2.8.3)
project(opencv_apps)

find_package(catkin REQUIRED COMPONENTS cv_bridge dynamic_reconfigure message_generation image_transport nodelet roscpp sensor_msgs)
find_package(catkin REQUIRED COMPONENTS cv_bridge dynamic_reconfigure message_generation image_transport image_geometry nodelet roscpp sensor_msgs)

find_package(OpenCV REQUIRED)
message(STATUS "OpenCV VERSION: ${OpenCV_VERSION}")
Expand Down Expand Up @@ -39,6 +39,7 @@ generate_dynamic_reconfigure_options(
cfg/CamShift.cfg
cfg/FBackFlow.cfg
cfg/LKFlow.cfg
cfg/MatchTemplate.cfg
cfg/PeopleDetect.cfg
cfg/PhaseCorr.cfg
cfg/SegmentObjects.cfg
Expand Down Expand Up @@ -158,7 +159,7 @@ opencv_apps_add_nodelet(discrete_fourier_transform discrete_fourier_transform/di
# ./tutorial_code/Histograms_Matching/calcHist_Demo.cpp
# ./tutorial_code/Histograms_Matching/compareHist_Demo.cpp
# ./tutorial_code/Histograms_Matching/EqualizeHist_Demo.cpp
# ./tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp
opencv_apps_add_nodelet(match_template match_template/match_template src/nodelet/match_template_nodelet.cpp) # ./tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp

# imagecodecs
# ./tutorial_code/imgcodecs/GDAL_IO/gdal-image.cpp
Expand Down
51 changes: 51 additions & 0 deletions cfg/MatchTemplate.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#! /usr/bin/env python
# Software License Agreement (BSD License)
#
# Copyright (c) 2017, Ryosuke Tajima
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of Kei Okada nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.


PACKAGE='match_template'

from dynamic_reconfigure.parameter_generator_catkin import *

gen = ParameterGenerator()
gen.add("use_camera_info", bool_t, 0, "Indicates that the camera_info topic should be subscribed to to get the default input_frame_id. Otherwise the frame from the image message will be used.", False)
match_type = gen.enum([gen.const("CV_TM_SQDIFF", int_t, 0, "Sum of Ssquared Difference"),
gen.const("CV_TM_SQDIFF_NORMED", int_t, 1, "Sum of Normalized Ssquared Difference"),
gen.const("CV_TM_CCORR", int_t, 2, "Correlation"),
gen.const("CV_TM_CCORR_NORMED", int_t, 3, "Normalized Correlation"),
gen.const("CV_TM_CCOEFF", int_t, 4, "Correlation of Coefficient"),
gen.const("CV_TM_CCOEFF_NORMED", int_t, 5, "Normalized Correlation of Coefficient"),
], "An enum for Mathing Mehtods")
gen.add("match_method", int_t, 0, "Matching Methods", 5, 0, 5, edit_method=match_type)
gen.add("match_threshold", double_t, 0, "Matching Threshold", 0.0, 0.0, 1.0)

exit(gen.generate(PACKAGE, "match_template", "MatchTemplate"))
21 changes: 21 additions & 0 deletions launch/match_template.launch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<launch>
<arg name="node_name" default="match_template" />
<arg name="image" default="image" doc="The image topic. Should be remapped to the name of the real image topic." />
<arg name="use_camera_info" default="false" doc="Indicates that the camera_info topic should be subscribed to to get the default input_frame_id. Otherwise the frame from the image message will be used." />
<arg name="debug_view" default="false" doc="Specify whether the node displays a window to show edge image" />
<arg name="match_method" default="5" doc="Matching method. 0:CV_TM_SQDIFF 1:CV_TM_SQDIFF_NORMED 2:CV_TM_CCORR 3:CV_TM_CCORR_NORMED 4:CV_TM_CCOEFF 5:CV_TM_CCOEFF_NORMED" />
<arg name="template_file" default="" doc="filename for template image"/>
<arg name="mask_file" default="" doc="filename for mask image"/>

<!-- match_template_nodelet.cpp -->
<node name="$(arg node_name)" pkg="opencv_apps" type="match_template" output="screen">
<remap from="image" to="$(arg image)" />
<param name="use_camera_info" value="$(arg use_camera_info)" />
<param name="debug_view" value="$(arg debug_view)" />
<param name="match_method" value="$(arg match_method)" />
<param name="use_mask" value="false" />
<param name="template_file" value="$(arg template_file)" />
<param name="mask_file" value="$(arg mask_file)" />
<param name="match_threshold" value="0.0"/>
</node>
</launch>
4 changes: 4 additions & 0 deletions nodelet_plugins.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
<description>Nodelet to calculate Lukas-Kanade optical flow</description>
</class>

<class name="match_template/match_template" type="match_template::MatchTemplateNodelet" base_class_type="nodelet::Nodelet">
<description>Nodelet to find the template on the image</description>
</class>

<class name="people_detect/people_detect" type="people_detect::PeopleDetectNodelet" base_class_type="nodelet::Nodelet">
<description>Nodelet to demonstrate the use of the HoG descriptor</description>
</class>
Expand Down
Loading