Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
LimaGroup
Lima
Commits
72a18cd8
Commit
72a18cd8
authored
Oct 06, 2020
by
Samuel Debionne
Browse files
Fix CtImage (more missing SwapDimIfRotated for binning)
parent
173e0870
Pipeline
#34766
passed with stages
in 29 minutes and 43 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
control/src/CtImage.cpp
View file @
72a18cd8
...
...
@@ -77,8 +77,8 @@ void CtSwBinRoiFlip::setMaxSize(Size& size)
m_max_size
=
size
;
// Comp
p
ute the full ROI according to the current rotation and binning
Roi
max_roi
(
Point
(
0
,
0
),
Size
(
SwapDimIfRotated
(
m_rotation
,
m_max_size
)
/
m_bin
));
// Compute the full ROI according to the current rotation and binning
Roi
max_roi
(
Point
(
0
,
0
),
SwapDimIfRotated
(
m_rotation
,
Size
(
m_max_size
/
m_bin
))
)
;
DEB_PARAM
()
<<
DEB_VAR1
(
max_roi
);
if
(
!
m_roi
.
isEmpty
())
{
...
...
@@ -99,10 +99,10 @@ void CtSwBinRoiFlip::setBin(const Bin& bin)
DEB_PARAM
()
<<
DEB_VAR1
(
bin
);
if
(
bin
!=
m_bin
)
{
m_roi
=
m_roi
.
getUnbinned
(
m_bin
);
m_roi
=
m_roi
.
getUnbinned
(
SwapDimIfRotated
(
m_rotation
,
m_bin
)
)
;
m_bin
=
bin
;
if
(
!
m_bin
.
isOne
())
m_roi
=
m_roi
.
getBinned
(
m_bin
);
m_roi
=
m_roi
.
getBinned
(
SwapDimIfRotated
(
m_rotation
,
m_bin
)
)
;
}
}
...
...
@@ -111,7 +111,7 @@ void CtSwBinRoiFlip::setRoi(const Roi& roi)
DEB_MEMBER_FUNCT
();
DEB_PARAM
()
<<
DEB_VAR1
(
roi
);
Roi
max_roi
(
Point
(
0
,
0
),
Size
(
SwapDimIfRotated
(
m_rotation
,
m_max_size
)
/
m_bin
));
Roi
max_roi
(
Point
(
0
,
0
),
SwapDimIfRotated
(
m_rotation
,
Size
(
m_max_size
/
m_bin
))
)
;
DEB_TRACE
()
<<
DEB_VAR1
(
max_roi
);
if
(
roi
.
isEmpty
())
...
...
@@ -142,7 +142,7 @@ const Size& CtSwBinRoiFlip::getSize() const
DEB_TRACE
()
<<
DEB_VAR3
(
m_max_size
,
m_bin
,
m_roi
);
if
(
m_roi
.
isEmpty
())
m_size
=
m_max_size
/
m_bin
;
m_size
=
SwapDimIfRotated
(
m_rotation
,
Size
(
m_max_size
/
m_bin
))
;
else
m_size
=
m_roi
.
getSize
();
...
...
@@ -728,10 +728,10 @@ void CtImage::setRoi(Roi& roi)
DEB_PARAM
()
<<
DEB_VAR1
(
roi
);
Bin
bin
;
getBin
(
bin
);
Size
full_size
=
m_max_size
/
bin
;
Roi
full
R
oi
(
Point
(
0
,
0
),
full_size
);
Roi
full
_r
oi
(
Point
(
0
,
0
),
full_size
);
RotationMode
aRotation
=
m_sw
->
getRotation
();
full
R
oi
=
full
R
oi
.
getRotated
(
aRotation
,
full_size
);
if
(
roi
.
isEmpty
()
||
roi
==
full
R
oi
)
{
full
_r
oi
=
full
_r
oi
.
getRotated
(
aRotation
,
full_size
);
if
(
roi
.
isEmpty
()
||
roi
==
full
_r
oi
)
{
resetRoi
();
return
;
}
...
...
@@ -770,6 +770,7 @@ void CtImage::_setHSBin(const Bin &bin)
DEB_PARAM
()
<<
DEB_VAR1
(
bin
);
Roi
user_roi
;
getRoi
(
user_roi
);
Bin
user_bin
;
getBin
(
user_bin
);
RotationMode
user_rot
;
getRotation
(
user_rot
);
if
(
m_hw
->
hasBinCapability
())
{
Bin
set_hw_bin
=
bin
;
...
...
@@ -781,8 +782,8 @@ void CtImage::_setHSBin(const Bin &bin)
Bin
set_sw_bin
=
bin
/
set_hw_bin
;
m_sw
->
setBin
(
set_sw_bin
);
}
user_roi
=
user_roi
.
getUnbinned
(
user_bin
);
user_roi
=
user_roi
.
getBinned
(
bin
);
user_roi
=
user_roi
.
getUnbinned
(
SwapDimIfRotated
(
user_rot
,
user_bin
)
)
;
user_roi
=
user_roi
.
getBinned
(
SwapDimIfRotated
(
user_rot
,
bin
)
)
;
_completeWithSoftRoi
(
user_roi
,
m_hw
->
getRealRoi
());
}
else
{
m_sw
->
setBin
(
bin
);
...
...
@@ -835,8 +836,9 @@ void CtImage::_completeWithSoftRoi(Roi roi_set,Roi hw_roi)
DEB_MEMBER_FUNCT
();
DEB_PARAM
()
<<
DEB_VAR2
(
roi_set
,
hw_roi
);
const
Size
&
max_roi_size
=
m_hw
->
getMaxRoiSize
();
Size
hw_max_roi_size
=
m_hw
->
getMaxRoiSize
();
const
Size
&
max_roi_size
=
hw_max_roi_size
/
m_sw
->
getBin
();
DEB_TRACE
()
<<
DEB_VAR2
(
max_roi_size
,
hw_max_roi_size
);
// First flip the hardware roi
const
Flip
&
aSoftwareFlip
=
m_sw
->
getFlip
();
...
...
@@ -874,7 +876,7 @@ void CtImage::setFlip(Flip &flip)
getRotation
(
currentRotation
);
Size
hw_max_roi_size
=
m_hw
->
getMaxRoiSize
();
Size
max_roi_size
=
SwapDimIfRotated
(
currentRotation
,
Size
(
hw_max_roi_size
/
m_sw
->
getBin
()
))
;
Size
max_roi_size
=
hw_max_roi_size
/
m_sw
->
getBin
();
DEB_TRACE
()
<<
DEB_VAR3
(
currentRoi
,
max_roi_size
,
hw_max_roi_size
);
currentRoi
=
currentRoi
.
getUnrotated
(
currentRotation
,
max_roi_size
);
...
...
@@ -920,7 +922,7 @@ void CtImage::setRotation(RotationMode rotation)
getBin
(
currentBin
);
Size
hw_max_roi_size
=
m_hw
->
getMaxRoiSize
();
Size
max_roi_size
=
SwapDimIfRotated
(
currentRotation
,
Size
(
hw_max_roi_size
/
m_sw
->
getBin
()
))
;
Size
max_roi_size
=
hw_max_roi_size
/
m_sw
->
getBin
();
DEB_TRACE
()
<<
DEB_VAR3
(
currentRoi
,
max_roi_size
,
hw_max_roi_size
);
currentRoi
=
currentRoi
.
getUnrotated
(
currentRotation
,
max_roi_size
);
...
...
control/test/test_roi_binrotflip.py
View file @
72a18cd8
...
...
@@ -5,8 +5,7 @@ from Lima import Core, Simulator
cam
=
Simulator
.
Camera
()
#frame_dim = Core.FrameDim(Core.Size(800, 600), Core.Bpp32)
frame_dim
=
Core
.
FrameDim
(
Core
.
Size
(
600
,
600
),
Core
.
Bpp32
)
frame_dim
=
Core
.
FrameDim
(
Core
.
Size
(
600
,
300
),
Core
.
Bpp32
)
cam
=
Simulator
.
Camera
()
getter
=
cam
.
getFrameGetter
()
getter
.
setFrameDim
(
frame_dim
)
...
...
@@ -19,8 +18,12 @@ acq.setAcqNbFrames(1)
acq
.
setAcqExpoTime
(
0.001
)
img
=
control
.
image
()
#roi = Core.Roi(300,50,450,300)
roi
=
Core
.
Roi
(
160
,
60
,
120
,
200
)
print
(
"Attach debugger now"
)
input
()
roi
=
Core
.
Roi
(
1
,
1
,
598
,
298
)
# Almost full frame
#roi = Core.Roi(0, 0, 600, 300) # Full frame
img
.
setRoi
(
roi
)
rots
=
[
Core
.
Rotation_0
,
Core
.
Rotation_90
,
Core
.
Rotation_180
,
Core
.
Rotation_270
]
...
...
@@ -47,28 +50,29 @@ def permutation(lst):
permutations
=
permutation
([
'b'
,
'f'
,
'r'
])
# For every permutation of every Bin Rot Flip parameters applied in any order
for
rot
in
rots
:
for
bin
in
binnings
:
for
flip
in
flips
:
for
perm
in
permutations
:
try
:
for
op
in
perm
:
if
op
==
'f'
:
img
.
setFlip
(
flip
)
elif
op
==
'b'
:
img
.
setBin
(
bin
)
elif
op
==
'r'
:
img
.
setRotation
(
rot
)
#print(perm, flip, rot, bin, img.getRoi(), " - OK")
except
Exception
:
print
(
perm
,
flip
,
rot
,
bin
,
img
.
getRoi
(),
" - FAILED"
)
img
.
resetBin
()
img
.
resetFlip
()
img
.
resetRotation
()
assert
img
.
getRoi
()
==
roi
try
:
# For every permutation of every Bin Rot Flip parameters applied in any order
for
rot
in
rots
:
for
bin
in
binnings
:
for
flip
in
flips
:
for
perm
in
permutations
:
for
op
in
perm
:
if
op
==
'f'
:
img
.
setFlip
(
flip
)
elif
op
==
'b'
:
img
.
setBin
(
bin
)
elif
op
==
'r'
:
img
.
setRotation
(
rot
)
#print(perm, flip, rot, bin, img.getRoi(), " - OK")
print
(
"All permutations tested"
)
# Final check
img
.
resetBin
()
img
.
resetFlip
()
img
.
resetRotation
()
except
Core
.
Exception
as
ex
:
if
ex
.
getErrType
()
==
Core
.
InvalidValue
:
print
(
perm
,
flip
,
rot
,
bin
,
img
.
getRoi
(),
" - FAILED"
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment