Skip to content

Commit

Permalink
renaming and some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
anacg1620 committed Jun 10, 2024
1 parent 18f8924 commit bb0d487
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// -*- mode:C++; tab-width:4; c-basic-offset:4; indent-tabs-mode:nil -*-

#include "ArucoDetector.hpp"
#include "ArucoCodeDetector.hpp"

#include <vector>

using namespace roboticslab;

bool ArucoDetector::open(yarp::os::Searchable& config)
bool ArucoCodeDetector::open(yarp::os::Searchable& config)
{
// default params
detectorParams = cv::aruco::DetectorParameters();
dictionary = cv::aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
}

bool ArucoDetector::detect(const yarp::sig::Image& inYarpImg, yarp::os::Bottle& detectedObjects)
bool ArucoCodeDetector::detect(const yarp::sig::Image& inYarpImg, yarp::os::Bottle& detectedObjects)
{
yarp::sig::ImageOf<yarp::sig::PixelBgr> inYarpImgBgr;
inYarpImgBgr.copy(inYarpImg);
Expand All @@ -22,8 +22,8 @@ bool ArucoDetector::detect(const yarp::sig::Image& inYarpImg, yarp::os::Bottle&
std::vector<int> markerIds;
std::vector<std::vector<cv::Point2f>> corners, rejectedCandidates;

cv::aruco::ArucoDetector arucoDetector(dictionary, detectorParams);
arucoDetector.detectMarkers(inputImage, corners, markerIds, rejectedCandidates);
cv::aruco::ArucoDetector detector(dictionary, detectorParams);
detector.detectMarkers(inputImage, corners, markerIds, rejectedCandidates);

for (auto i = 0; i < corners.size() / 4; i++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@

#include <yarp/dev/DeviceDriver.h>
#include <opencv2/objdetect.hpp>
#include <opencv2/objdetect/aruco_detector.hpp>
#include "IDetector.hpp"

namespace roboticslab
{

/**
* @ingroup YarpPlugins
* @defgroup ArucoDetector
* @brief Contains roboticslab::ArucoDetector.
* @defgroup ArucoCodeDetector
* @brief Contains roboticslab::ArucoCodeDetector.
*/

class ArucoDetector : public yarp::dev::DeviceDriver,
public IDetector
class ArucoCodeDetector : public yarp::dev::DeviceDriver,
public IDetector
{
public:
bool open(yarp::os::Searchable& config) override;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
if(NOT DEFINED ENABLE_ArucoDetector OR ENABLE_ArucoDetector)
if(NOT DEFINED ENABLE_ArucoCodeDetector OR ENABLE_ArucoCodeDetector)
if(NOT TARGET opencv_objdetect)
message(WARNING "OpenCV objdetect module not found, disabling ArucoDetector device")
message(WARNING "OpenCV objdetect module not found, disabling ArucoCodeDetector device")
elseif(NOT YARP_cv_FOUND)
message(WARNING "YARP_cv package not found, disabling ArucoDetector device")
message(WARNING "YARP_cv package not found, disabling ArucoCodeDetector device")
endif()
endif()

yarp_prepare_plugin(ArucoDetector
yarp_prepare_plugin(ArucoCodeDetector
CATEGORY device
TYPE roboticslab::ArucoDetector
INCLUDE ArucoDetector.hpp
TYPE roboticslab::ArucoCodeDetector
INCLUDE ArucoCodeDetector.hpp
DEFAULT ON
DEPENDS "TARGET opencv_objdetect;YARP_cv_FOUND")

if(NOT SKIP_ArucoDetector)
if(NOT SKIP_ArucoCodeDetector)

yarp_add_plugin(ArucoDetector ArucoDetector.hpp
ArucoDetector.cpp)
yarp_add_plugin(ArucoCodeDetector ArucoCodeDetector.hpp
ArucoCodeDetector.cpp)

target_link_libraries(ArucoDetector YARP::YARP_os
target_link_libraries(ArucoCodeDetector YARP::YARP_os
YARP::YARP_dev
YARP::YARP_cv
opencv_objdetect
ROBOTICSLAB::VisionInterfaces)

yarp_install(TARGETS ArucoDetector
yarp_install(TARGETS ArucoCodeDetector
LIBRARY DESTINATION ${ROBOTICSLAB-VISION_DYNAMIC_PLUGINS_INSTALL_DIR}
ARCHIVE DESTINATION ${ROBOTICSLAB-VISION_STATIC_PLUGINS_INSTALL_DIR}
YARP_INI DESTINATION ${ROBOTICSLAB-VISION_PLUGIN_MANIFESTS_INSTALL_DIR})

else()

set(ENABLE_ArucoDetector OFF CACHE BOOL "Enable/disable ArucoDetector device" FORCE)
set(ENABLE_ArucoCodeDetector OFF CACHE BOOL "Enable/disable ArucoCodeDetector device" FORCE)

endif()
1 change: 1 addition & 0 deletions libraries/YarpPlugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ add_subdirectory(ColorRegionDetector)
add_subdirectory(DnnDetector)
add_subdirectory(HaarDetector)
add_subdirectory(QrDetector)
add_subdirectory(ArucoCodeDetector)

0 comments on commit bb0d487

Please sign in to comment.