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
8f68612e
Commit
8f68612e
authored
3 years ago
by
Max Breitenfeldt
Browse files
Options
Downloads
Patches
Plain Diff
Refactor shared memory initialization
parent
0379ba57
No related branches found
No related tags found
No related merge requests found
Pipeline
#39509
failed
3 years ago
Stage: build
Stage: package
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Src/Model/BioTrackerTrackingAlgorithm.cpp
+19
-21
19 additions, 21 deletions
Src/Model/BioTrackerTrackingAlgorithm.cpp
Src/Model/BioTrackerTrackingAlgorithm.h
+1
-1
1 addition, 1 deletion
Src/Model/BioTrackerTrackingAlgorithm.h
with
20 additions
and
22 deletions
Src/Model/BioTrackerTrackingAlgorithm.cpp
+
19
−
21
View file @
8f68612e
...
...
@@ -18,24 +18,6 @@
using
json
=
nlohmann
::
json
;
void
*
init_shm_mmap
(
const
char
*
path
,
int
len
)
{
int
fd
=
shm_open
(
path
,
O_RDWR
,
0
);
if
(
fd
==
-
1
)
{
throw
"shm_open"
;
}
void
*
shm_buf
=
mmap
(
NULL
,
len
,
PROT_READ
|
PROT_WRITE
,
MAP_SHARED
,
fd
,
0
);
close
(
fd
);
if
(
shm_buf
==
MAP_FAILED
)
{
throw
"mmap"
;
}
return
shm_buf
;
}
BioTrackerTrackingAlgorithm
::
BioTrackerTrackingAlgorithm
(
IController
*
parent
,
IModel
*
parameter
,
IModel
*
trajectory
)
:
IModelTrackingAlgorithm
(
parent
)
{
...
...
@@ -55,7 +37,7 @@ BioTrackerTrackingAlgorithm::~BioTrackerTrackingAlgorithm()
stop_python
();
}
void
BioTrackerTrackingAlgorithm
::
reques
t_shared_memory
()
{
void
BioTrackerTrackingAlgorithm
::
ini
t_shared_memory
()
{
json
j
=
{
{
"type"
,
"request_shared_memory"
},
{
"width"
,
_imageX
},
...
...
@@ -65,7 +47,23 @@ void BioTrackerTrackingAlgorithm::request_shared_memory() {
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"
].
get
<
std
::
string
>
();
_shm_img
=
(
float
*
)
init_shm_mmap
(
shm_path
.
c_str
(),
_imageX
*
_imageY
*
sizeof
(
float
));
int
shm_len
=
_imageX
*
_imageY
*
sizeof
(
float
);
int
fd
=
shm_open
(
shm_path
.
c_str
(),
O_RDWR
,
0
);
if
(
fd
==
-
1
)
{
throw
"shm_open"
;
}
void
*
shm_buf
=
mmap
(
NULL
,
shm_len
,
PROT_READ
|
PROT_WRITE
,
MAP_SHARED
,
fd
,
0
);
close
(
fd
);
if
(
shm_buf
==
MAP_FAILED
)
{
throw
"mmap"
;
}
_shm_img
=
(
float
*
)
shm_buf
;
}
void
BioTrackerTrackingAlgorithm
::
stop_python
()
{
...
...
@@ -112,7 +110,7 @@ void BioTrackerTrackingAlgorithm::doTracking(std::shared_ptr<cv::Mat> p_image, u
if
(
_imageX
!=
p_image
->
size
().
width
||
_imageY
!=
p_image
->
size
().
height
)
{
_imageX
=
p_image
->
size
().
width
;
_imageY
=
p_image
->
size
().
height
;
reques
t_shared_memory
();
ini
t_shared_memory
();
Q_EMIT
emitDimensionUpdate
(
_imageX
,
_imageY
);
}
...
...
This diff is collapsed.
Click to expand it.
Src/Model/BioTrackerTrackingAlgorithm.h
+
1
−
1
View file @
8f68612e
...
...
@@ -38,7 +38,7 @@ public Q_SLOTS:
void
receiveParametersChanged
();
private:
void
reques
t_shared_memory
();
void
ini
t_shared_memory
();
void
start_python
();
void
stop_python
();
...
...
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