Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
python_tracker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
swp21_biotracker
python_tracker
Commits
366c6ed2
Commit
366c6ed2
authored
3 years ago
by
Max Breitenfeldt
Browse files
Options
Downloads
Patches
Plain Diff
Add json fish poses to trajectory
parent
bfd7abd0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Src/Model/BioTrackerTrackingAlgorithm.cpp
+33
-1
33 additions, 1 deletion
Src/Model/BioTrackerTrackingAlgorithm.cpp
with
33 additions
and
1 deletion
Src/Model/BioTrackerTrackingAlgorithm.cpp
+
33
−
1
View file @
366c6ed2
...
...
@@ -11,8 +11,10 @@
#include
"BioTrackerTrackingAlgorithm.h"
#include
<future>
#include
"TrackedComponents/TrackedComponentFactory.h"
#include
"TrackedComponents/pose/FishPose.h"
#include
<chrono>
#include
<zmq.hpp>
#define JSON_USE_IMPLICIT_CONVERSIONS 0
#include
"json.hpp"
using
json
=
nlohmann
::
json
;
...
...
@@ -70,7 +72,7 @@ void BioTrackerTrackingAlgorithm::request_shared_memory() {
_sock
.
send
(
zmq
::
buffer
(
j
.
dump
()));
auto
res
=
_sock
.
recv
(
_zmq_msg
,
zmq
::
recv_flags
::
none
);
auto
msg
=
json
::
parse
(
_zmq_msg
.
to_string_view
());
std
::
string
shm_path
=
msg
[
"path"
];
std
::
string
shm_path
=
msg
[
"path"
]
.
get
<
std
::
string
>
()
;
_shm_img
=
(
float
*
)
init_shm_mmap
(
shm_path
.
c_str
(),
_imageX
*
_imageY
*
sizeof
(
float
));
}
...
...
@@ -113,6 +115,8 @@ void BioTrackerTrackingAlgorithm::doTracking(std::shared_ptr<cv::Mat> p_image, u
return
;
}
std
::
chrono
::
system_clock
::
time_point
start
=
std
::
chrono
::
system_clock
::
now
();
cv
::
Mat
grayscale
,
float_img
;
cv
::
cvtColor
(
*
p_image
,
grayscale
,
cv
::
COLOR_BGR2GRAY
);
grayscale
.
convertTo
(
float_img
,
CV_32F
);
...
...
@@ -128,6 +132,34 @@ void BioTrackerTrackingAlgorithm::doTracking(std::shared_ptr<cv::Mat> p_image, u
auto
res
=
_sock
.
recv
(
_zmq_msg
,
zmq
::
recv_flags
::
none
);
auto
msg
=
json
::
parse
(
_zmq_msg
.
to_string_view
());
std
::
vector
<
FishPose
>
poses
;
for
(
auto
pos
:
msg
[
"data"
])
{
auto
pose
=
FishPose
(
cv
::
Point2f
(
1.0
,
1.0
),
// FIXME: Calculate cm
cv
::
Point2f
(
pos
[
"x"
].
get
<
int
>
(),
pos
[
"y"
].
get
<
int
>
()),
pos
[
"orientation"
].
get
<
float
>
(),
pos
[
"orientation"
].
get
<
float
>
()
*
(
180.0
/
CV_PI
),
1.0
,
// FIXME: width
1.0
,
// FIXME: height
1.0
// FIXME: score
);
poses
.
push_back
(
pose
);
}
//Insert new poses into data structure
int
trajNumber
=
0
;
for
(
int
i
=
0
;
i
<
_TrackedTrajectoryMajor
->
size
();
i
++
)
{
BST
::
TrackedTrajectory
*
t
=
dynamic_cast
<
BST
::
TrackedTrajectory
*>
(
_TrackedTrajectoryMajor
->
getChild
(
i
));
if
(
t
&&
t
->
getValid
()
&&
!
t
->
getFixed
())
{
BST
::
TrackedElement
*
e
=
new
BST
::
TrackedElement
(
t
,
"n.a."
,
t
->
getId
());
e
->
setFishPose
(
poses
[
trajNumber
]);
e
->
setTime
(
start
);
t
->
add
(
e
,
framenumber
);
trajNumber
++
;
}
}
std
::
string
newSel
=
_TrackingParameter
->
getNewSelection
();
Q_EMIT
emitChangeDisplayImage
(
"Original"
);
...
...
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