Skip to content
Snippets Groups Projects
Commit b68ae2e3 authored by d.kilic's avatar d.kilic Committed by d.kilic
Browse files

Reviewer comments

parent 069076c7
No related branches found
No related tags found
1 merge request!73Implemented aruco marker visualization with offset
......@@ -49,16 +49,17 @@ private:
Vec2F mUlc; // upper left corner to draw
public:
CodeMarkerItem(QWidget *wParent, QGraphicsItem * parent = NULL);
QRectF boundingRect() const;
CodeMarkerItem(QWidget *wParent, QGraphicsItem * parent = nullptr);
QRectF boundingRect() const override;
void setRect(Vec2F& v);
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
void addDetectedMarkers(std::vector<std::vector<cv::Point2f> > corners, std::vector<int> ids, Vec2F offset = Vec2F(0,0));
void addRejectedMarkers(std::vector<std::vector<cv::Point2f> > rejected, Vec2F offset = Vec2F(0,0));
void resetSavedMarkers();
private:
void drawMarker(const OffsetMarker& currentMarker, int id, const QColor& borderColor, QPainter *painter);
static constexpr int numCorners = 4;
};
#endif
......@@ -129,14 +129,23 @@ void CodeMarkerItem::paint(QPainter *painter, const QStyleOptionGraphicsItem */*
}
inline void CodeMarkerItem::drawMarker(const OffsetMarker& currentMarker, int id, const QColor& borderColor, QPainter *painter)
/**
* @brief Draws a aruco code marker
*
* Draws a rect with the corners of the marker, the id, and the upper left corner.
*
* @param currentMarker
* @param id
* @param borderColor
* @param painter
*/
void CodeMarkerItem::drawMarker(const OffsetMarker& currentMarker, int id, const QColor& borderColor, QPainter *painter)
{
Vec2F offset = currentMarker.offset;
// draw marker sides
for(int j = 0; j < 4; j++) {
for(int j = 0; j < numCorners; j++) {
Vec2F p0 = currentMarker.corners.at(j);
Vec2F p1 = currentMarker.corners.at((j + 1) % 4);
// debout << "p0: " << p0 << " p1: " << p1 << endl;
Vec2F p1 = currentMarker.corners.at((j + 1) % numCorners);
painter->setPen(borderColor);
painter->drawLine((mUlc + p0 + offset).toQPointF(), (mUlc + p1 + offset).toQPointF());
}
......@@ -148,6 +157,15 @@ inline void CodeMarkerItem::drawMarker(const OffsetMarker& currentMarker, int id
painter->drawRect(QRectF((mUlc + topLeftCorner + offset - Vec2F(3,3)).toQPointF(), QSize(6.0,6.0)));
}
/**
* @brief Adds given markers as detected markers to visualization
*
* @pre ids[i] is the id of corners[i]
*
* @param corners corners of the markers
* @param ids ids of the detected markers
* @param offset offset from marker-coords to recognition ROI
*/
void CodeMarkerItem::addDetectedMarkers(vector<vector<Point2f> > corners, vector<int> ids, Vec2F offset /* = (0,0)*/)
{
for(std::vector<Point2f> singleMarkerCorners : corners)
......@@ -157,6 +175,12 @@ void CodeMarkerItem::addDetectedMarkers(vector<vector<Point2f> > corners, vector
mIds.insert(mIds.end(), ids.begin(), ids.end());
}
/**
* @brief Adds given markers as rejected markers to visualization
*
* @param rejected corners of the rejected markers
* @param offset offset from marker-coords to recognition ROI
*/
void CodeMarkerItem::addRejectedMarkers(vector<vector<Point2f> > rejected, Vec2F offset /* = (0,0)*/)
{
for(std::vector<Point2f> singleMarkerCorners : rejected)
......@@ -165,6 +189,9 @@ void CodeMarkerItem::addRejectedMarkers(vector<vector<Point2f> > rejected, Vec2F
}
}
/**
* @brief Resets detected and rejected markers for visualization
*/
void CodeMarkerItem::resetSavedMarkers()
{
mCorners.clear();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment