Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
PeTrack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pedestrian Dynamics Empiricism
PeTrack
Commits
b68ae2e3
Commit
b68ae2e3
authored
4 years ago
by
d.kilic
Committed by
d.kilic
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Reviewer comments
parent
069076c7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!73
Implemented aruco marker visualization with offset
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/codeMarkerItem.h
+4
-3
4 additions, 3 deletions
include/codeMarkerItem.h
src/codeMarkerItem.cpp
+31
-4
31 additions, 4 deletions
src/codeMarkerItem.cpp
with
35 additions
and
7 deletions
include/codeMarkerItem.h
+
4
−
3
View file @
b68ae2e3
...
...
@@ -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
This diff is collapsed.
Click to expand it.
src/codeMarkerItem.cpp
+
31
−
4
View file @
b68ae2e3
...
...
@@ -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
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment