Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NdlS 2024
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
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AR_Sandbox
NdlS 2024
Commits
720910b1
Commit
720910b1
authored
Jul 5, 2024
by
Adrien Lescourt
Browse files
Options
Downloads
Patches
Plain Diff
Kevin stuff
parent
6d2792f9
No related branches found
No related tags found
1 merge request
!1
2024
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
aruco_tags.json
+1
-0
1 addition, 0 deletions
aruco_tags.json
demo.py
+78
-10
78 additions, 10 deletions
demo.py
env.sh
+2
-1
2 additions, 1 deletion
env.sh
sandbox_conf.yaml
+25
-17
25 additions, 17 deletions
sandbox_conf.yaml
with
106 additions
and
28 deletions
aruco_tags.json
0 → 100644
+
1
−
0
View file @
720910b1
{
"arucos"
:
[]}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
demo.py
+
78
−
10
View file @
720910b1
# import json
# from ar_sandbox import Sandbox
# from ar_sandbox import Sandbox
# import sys
# import cv2
# import numpy as np
# import numpy.ma as npma
# from esrimap.esrimap import EsriAscii
# from PIL import Image
# import requests
# import time
# import math
from
ar_sandbox
import
Sandbox
# from ar_sandbox.wrapper import sandbox_wrapper as sw
# from ar_sandbox.wrapper import sandbox_wrapper as sw
import
sys
import
sys
import
cv2
import
cv2
...
@@ -9,6 +22,14 @@ from PIL import Image
...
@@ -9,6 +22,14 @@ from PIL import Image
import
requests
import
requests
import
time
import
time
import
math
import
math
import
json
# EDIT ME
DEFAULT_URL
=
"
http://172.30.255.2:8000/map
"
DEFAULT_URL2
=
"
http://10.136.217.168:8000/map
"
destinations
=
[
DEFAULT_URL
]
NORMALIZATION_BETWEEN
=
(
0.8
,
1.2
)
NORMALIZATION_BETWEEN
=
(
0.8
,
1.2
)
...
@@ -66,7 +87,6 @@ COLOR_B_HARD = [c[1][2] for c in COLORS_FULL_SPECTRUM_HARD]
...
@@ -66,7 +87,6 @@ COLOR_B_HARD = [c[1][2] for c in COLORS_FULL_SPECTRUM_HARD]
COLORMAP
=
None
COLORMAP
=
None
COLORMAP_HARD
=
None
COLORMAP_HARD
=
None
DEFAULT_URL
=
"
http://localhost:8000
"
def
try_and_ignore
(
ignore
=
Exception
,
default_value
=
0.0
):
def
try_and_ignore
(
ignore
=
Exception
,
default_value
=
0.0
):
...
@@ -172,12 +192,15 @@ def display_level(frame):
...
@@ -172,12 +192,15 @@ def display_level(frame):
def
send_request
(
body
,
url
=
"
http://localhost:8000/map
"
):
def
send_request
(
body
,
url
=
"
http://localhost:8000/map
"
):
# with open("mapoutput.asc", "w") as fp:
# json.dump(fp, body)
try
:
try
:
requests
.
post
(
url
,
json
=
body
)
requests
.
post
(
url
,
json
=
body
)
except
Exception
as
e
:
except
Exception
as
e
:
print
(
e
)
print
(
e
)
# This is the older method that was used to transmit arucos over the network
def
build_req_body
(
map
,
tag_list
):
def
build_req_body
(
map
,
tag_list
):
arucos
=
[]
arucos
=
[]
for
t
in
tag_list
:
for
t
in
tag_list
:
...
@@ -201,6 +224,29 @@ def build_req_body(map, tag_list):
...
@@ -201,6 +224,29 @@ def build_req_body(map, tag_list):
return
body
return
body
# This new method is basically a copy pasted version of the one above without the map
# Maybe both of them are not needed anymore
def
build_arucos_json
(
tag_list
):
arucos
=
[]
for
t
in
tag_list
:
print
(
t
)
(
x
,
y
),
id
,
r
=
t
(
x
,
y
)
=
(
parse_int
(
x
),
parse_int
(
y
))
id
=
parse_int
(
id
)
r
=
parse_float
(
r
)
arucos
.
append
({
"
tag_id
"
:
id
,
"
position
"
:
{
"
x
"
:
x
,
"
y
"
:
y
},
"
rotation
"
:
r
})
body
=
{
"
arucos
"
:
arucos
}
return
body
def
normalize_array
(
array
):
def
normalize_array
(
array
):
return
(
array
-
array
.
min
())
/
(
array
.
max
()
-
array
.
min
())
return
(
array
-
array
.
min
())
/
(
array
.
max
()
-
array
.
min
())
...
@@ -241,16 +287,30 @@ def make_esri_and_send(depth, color, *args):
...
@@ -241,16 +287,30 @@ def make_esri_and_send(depth, color, *args):
# Aruco detection
# Aruco detection
grayscale_frame
=
cv2
.
cvtColor
(
color
,
cv2
.
COLOR_BGR2GRAY
)
grayscale_frame
=
cv2
.
cvtColor
(
color
,
cv2
.
COLOR_BGR2GRAY
)
_
,
(
corn
,
ids
,
rej
),
centers
,
rots
=
detect_aruco
(
grayscale_frame
)
_
,
(
corn
,
ids
,
rej
),
centers
,
rots
=
detect_aruco
(
grayscale_frame
)
#TODO
# Create map and tag dictionary
# Create map and tag dictionary
esri_map
=
EsriAscii
.
from_ndarray
(
depth
)
esri_map
=
EsriAscii
.
from_ndarray
(
depth
)
detected
=
build_tag_list
(
ids
,
centers
,
rots
)
detected
=
build_tag_list
(
ids
,
centers
,
rots
)
#TODO
# Send it toward api
# Send it toward api
send_request
(
build_req_body
(
esri_map
,
detected
),
url
=
DEFAULT_URL
)
#send_request(build_req_body(esri_map, detected), url=DEFAULT_URL)
# May locally save the esri_map
for
dest
in
destinations
:
# esri_map.to_file("depth_map_v2.asc")
pass
#TODO
#send_request(build_req_body(esri_map, detected), url=dest)
#send_request(build_req_body(esri_map, []), url=dest)
#send_request(build_req_body(esri_map, detected), url=DEFAULT_URL2)
# May locally save the esri_map & arucos
esri_map
.
to_file
(
"
depth_map.asc
"
)
tags
=
build_arucos_json
(
detected
)
print
(
tags
)
with
open
(
"
aruco_tags.json
"
,
"
w
"
)
as
fp
:
json
.
dump
(
tags
,
fp
)
# Return value will be displayed on the beamer
# Return value will be displayed on the beamer
return
levels
return
levels
...
@@ -266,12 +326,19 @@ def get_center(corner):
...
@@ -266,12 +326,19 @@ def get_center(corner):
c0
,
_
,
c2
,
_
=
corner
[
0
]
c0
,
_
,
c2
,
_
=
corner
[
0
]
return
int
(
c0
[
0
]
+
(
c2
[
0
]
-
c0
[
0
])
//
2
),
int
(
c0
[
1
]
+
(
c2
[
1
]
-
c0
[
1
])
//
2
)
return
int
(
c0
[
0
]
+
(
c2
[
0
]
-
c0
[
0
])
//
2
),
int
(
c0
[
1
]
+
(
c2
[
1
]
-
c0
[
1
])
//
2
)
# TODO def detect_aruco(a, b=None, c=None): return
def
detect_aruco
(
frame
,
def
detect_aruco
(
frame
,
aruco_dict
=
cv2
.
aruco
.
Dictionary_get
(
cv2
.
aruco
.
DICT_4X4_50
),
#aruco_dict=cv2.aruco.Dictionary_get(cv2.aruco.DICT_4X4_50),
aruco_params
=
cv2
.
aruco
.
DetectorParameters_create
()):
#aruco_params=cv2.aruco.DetectorParameters_create()):
aruco_dict
=
cv2
.
aruco
.
getPredefinedDictionary
(
cv2
.
aruco
.
DICT_4X4_50
),
aruco_params
=
cv2
.
aruco
.
DetectorParameters
()):
output
=
frame
.
copy
()
output
=
frame
.
copy
()
(
corners
,
ids
,
rejected
)
=
cv2
.
aruco
.
detectMarkers
(
frame
,
aruco_dict
,
parameters
=
aruco_params
)
#(corners, ids, rejected) = cv2.aruco.detectMarkers(frame, aruco_dict, parameters=aruco_params)
detector
=
cv2
.
aruco
.
ArucoDetector
(
aruco_dict
,
aruco_params
)
(
corners
,
ids
,
rejected
)
=
detector
.
detectMarkers
(
frame
)
centers
=
[]
centers
=
[]
rotations
=
[]
rotations
=
[]
for
c
in
range
(
len
(
corners
)):
for
c
in
range
(
len
(
corners
)):
...
@@ -376,7 +443,8 @@ if __name__ == "__main__":
...
@@ -376,7 +443,8 @@ if __name__ == "__main__":
# USE_HARD_COLORS=True
# USE_HARD_COLORS=True
LINE_COLORS
=
[
0
,
0
,
0
]
LINE_COLORS
=
[
0
,
0
,
0
]
box
=
FakeSandbox
(
refresh
=
1000
)
box
=
Sandbox
(
refresh
=
1000
)
box
.
verbosity
=
5
box
.
init
()
box
.
init
()
box
.
on_frame
=
make_esri_and_send
box
.
on_frame
=
make_esri_and_send
box
.
start
(
box
)
box
.
start
(
box
)
This diff is collapsed.
Click to expand it.
env.sh
+
2
−
1
View file @
720910b1
export
LD_LIBRARY_PATH
=
/home/alexis/sandbox/sandbox_docker-builder/build/lib/
#export LD_LIBRARY_PATH=/home/alexis/sandbox/sandbox_docker-builder/build/lib/
export
LD_LIBRARY_PATH
=
/home/sandbox/Documents/ar_sandbox_lib/build
This diff is collapsed.
Click to expand it.
sandbox_conf.yaml
+
25
−
17
View file @
720910b1
AdjustingMatrix
:
AdjustingMatrix
:
angle
:
1.4119340386036046
#angle: 0.5119340386036046
angle
:
0.5
width
:
3
width
:
3
height
:
2
height
:
2
matrix
:
[
0.999696374
,
0.0246404037
,
0
,
-0.0246404037
,
0.999696374
,
0
]
matrix
:
[
1.0
,
0
,
50
,
-0
,
1
,
50
]
#matrix: [0.999696374, 0.0246404037, 0, -0.0246404037, 0.999696374, 0]
# [?, rotation, ?, ?, ?, ?]
#angle: 0
#width: 3
#height: 2
#matrix: [1, 0, 0, -0, 1, 0]
DistanceTopSandbox
:
DistanceTopSandbox
:
distance
:
1
distance
:
1
.11300004
CroppingMask
:
CroppingMask
:
x
:
52
x
:
52
y
:
19
y
:
19
width
:
588
# 568
width
:
588
height
:
43
2
height
:
43
7
BeamerResolution
:
BeamerResolution
:
width
:
1
40
0
width
:
1
28
0
height
:
10
50
height
:
10
24
BeamerPosition
:
BeamerPosition
:
x
:
0.0536931753
x
:
-0.0419691354
y
:
0.260815978
#x: -0.0419691354
z
:
-0.325273067
y
:
0.238534391
z
:
-0.126809254
FrameProcessProfil
:
FrameProcessProfil
:
contrast
:
1.
09
00000000000001
contrast
:
1.
12
00000000000001
brightness
:
14
brightness
:
-
14
8
minDistance
:
1
5
minDistance
:
1
00
cannyEdgeThreshold
:
184
cannyEdgeThreshold
:
86
houghAccThreshold
:
35
houghAccThreshold
:
44
minRadius
:
0
minRadius
:
2
maxRadius
:
0
maxRadius
:
14
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
sign in
to comment