Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
b3a07166
Commit
b3a07166
authored
Jan 18, 2020
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #16350 from hannesa2:fixLintIssuesAndroid
parents
282fcb90
4057e81b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
18 deletions
+18
-18
Puzzle15Activity.java
...zle/src/org/opencv/samples/puzzle15/Puzzle15Activity.java
+1
-1
CalibrationResult.java
...g/opencv/samples/cameracalibration/CalibrationResult.java
+10
-10
CameraCalibrator.java
...rg/opencv/samples/cameracalibration/CameraCalibrator.java
+7
-7
No files found.
samples/android/15-puzzle/src/org/opencv/samples/puzzle15/Puzzle15Activity.java
View file @
b3a07166
...
...
@@ -22,7 +22,7 @@ import java.util.List;
public
class
Puzzle15Activity
extends
CameraActivity
implements
CvCameraViewListener
,
View
.
OnTouchListener
{
private
static
final
String
TAG
=
"
Sample::
Puzzle15::Activity"
;
private
static
final
String
TAG
=
"Puzzle15::Activity"
;
private
CameraBridgeViewBase
mOpenCvCameraView
;
private
Puzzle15Processor
mPuzzle15
;
...
...
samples/android/camera-calibration/src/org/opencv/samples/cameracalibration/CalibrationResult.java
View file @
b3a07166
...
...
@@ -8,7 +8,7 @@ import android.content.SharedPreferences;
import
android.util.Log
;
public
abstract
class
CalibrationResult
{
private
static
final
String
TAG
=
"OCV
Sample
::CalibrationResult"
;
private
static
final
String
TAG
=
"OCV::CalibrationResult"
;
private
static
final
int
CAMERA_MATRIX_ROWS
=
3
;
private
static
final
int
CAMERA_MATRIX_COLS
=
3
;
...
...
@@ -22,19 +22,19 @@ public abstract class CalibrationResult {
cameraMatrix
.
get
(
0
,
0
,
cameraMatrixArray
);
for
(
int
i
=
0
;
i
<
CAMERA_MATRIX_ROWS
;
i
++)
{
for
(
int
j
=
0
;
j
<
CAMERA_MATRIX_COLS
;
j
++)
{
Integer
id
=
i
*
CAMERA_MATRIX_ROWS
+
j
;
editor
.
putFloat
(
id
.
toString
(
),
(
float
)
cameraMatrixArray
[
id
]);
int
id
=
i
*
CAMERA_MATRIX_ROWS
+
j
;
editor
.
putFloat
(
Integer
.
toString
(
id
),
(
float
)
cameraMatrixArray
[
id
]);
}
}
double
[]
distortionCoefficientsArray
=
new
double
[
DISTORTION_COEFFICIENTS_SIZE
];
distortionCoefficients
.
get
(
0
,
0
,
distortionCoefficientsArray
);
int
shift
=
CAMERA_MATRIX_ROWS
*
CAMERA_MATRIX_COLS
;
for
(
Integer
i
=
shift
;
i
<
DISTORTION_COEFFICIENTS_SIZE
+
shift
;
i
++)
{
editor
.
putFloat
(
i
.
toString
(
),
(
float
)
distortionCoefficientsArray
[
i
-
shift
]);
for
(
int
i
=
shift
;
i
<
DISTORTION_COEFFICIENTS_SIZE
+
shift
;
i
++)
{
editor
.
putFloat
(
Integer
.
toString
(
i
),
(
float
)
distortionCoefficientsArray
[
i
-
shift
]);
}
editor
.
commit
();
editor
.
apply
();
Log
.
i
(
TAG
,
"Saved camera matrix: "
+
cameraMatrix
.
dump
());
Log
.
i
(
TAG
,
"Saved distortion coefficients: "
+
distortionCoefficients
.
dump
());
}
...
...
@@ -49,8 +49,8 @@ public abstract class CalibrationResult {
double
[]
cameraMatrixArray
=
new
double
[
CAMERA_MATRIX_ROWS
*
CAMERA_MATRIX_COLS
];
for
(
int
i
=
0
;
i
<
CAMERA_MATRIX_ROWS
;
i
++)
{
for
(
int
j
=
0
;
j
<
CAMERA_MATRIX_COLS
;
j
++)
{
Integer
id
=
i
*
CAMERA_MATRIX_ROWS
+
j
;
cameraMatrixArray
[
id
]
=
sharedPref
.
getFloat
(
id
.
toString
(
),
-
1
);
int
id
=
i
*
CAMERA_MATRIX_ROWS
+
j
;
cameraMatrixArray
[
id
]
=
sharedPref
.
getFloat
(
Integer
.
toString
(
id
),
-
1
);
}
}
cameraMatrix
.
put
(
0
,
0
,
cameraMatrixArray
);
...
...
@@ -58,8 +58,8 @@ public abstract class CalibrationResult {
double
[]
distortionCoefficientsArray
=
new
double
[
DISTORTION_COEFFICIENTS_SIZE
];
int
shift
=
CAMERA_MATRIX_ROWS
*
CAMERA_MATRIX_COLS
;
for
(
Integer
i
=
shift
;
i
<
DISTORTION_COEFFICIENTS_SIZE
+
shift
;
i
++)
{
distortionCoefficientsArray
[
i
-
shift
]
=
sharedPref
.
getFloat
(
i
.
toString
(
),
-
1
);
for
(
int
i
=
shift
;
i
<
DISTORTION_COEFFICIENTS_SIZE
+
shift
;
i
++)
{
distortionCoefficientsArray
[
i
-
shift
]
=
sharedPref
.
getFloat
(
Integer
.
toString
(
i
),
-
1
);
}
distortionCoefficients
.
put
(
0
,
0
,
distortionCoefficientsArray
);
Log
.
i
(
TAG
,
"Loaded distortion coefficients: "
+
distortionCoefficients
.
dump
());
...
...
samples/android/camera-calibration/src/org/opencv/samples/cameracalibration/CameraCalibrator.java
View file @
b3a07166
...
...
@@ -18,13 +18,13 @@ import org.opencv.imgproc.Imgproc;
import
android.util.Log
;
public
class
CameraCalibrator
{
private
static
final
String
TAG
=
"OCV
Sample
::CameraCalibrator"
;
private
static
final
String
TAG
=
"OCV::CameraCalibrator"
;
private
final
Size
mPatternSize
=
new
Size
(
4
,
11
);
private
final
int
mCornersSize
=
(
int
)(
mPatternSize
.
width
*
mPatternSize
.
height
);
private
boolean
mPatternWasFound
=
false
;
private
MatOfPoint2f
mCorners
=
new
MatOfPoint2f
();
private
List
<
Mat
>
mCornersBuffer
=
new
ArrayList
<
Mat
>();
private
List
<
Mat
>
mCornersBuffer
=
new
ArrayList
<>();
private
boolean
mIsCalibrated
=
false
;
private
Mat
mCameraMatrix
=
new
Mat
();
...
...
@@ -53,10 +53,10 @@ public class CameraCalibrator {
}
public
void
calibrate
()
{
ArrayList
<
Mat
>
rvecs
=
new
ArrayList
<
Mat
>();
ArrayList
<
Mat
>
tvecs
=
new
ArrayList
<
Mat
>();
ArrayList
<
Mat
>
rvecs
=
new
ArrayList
<>();
ArrayList
<
Mat
>
tvecs
=
new
ArrayList
<>();
Mat
reprojectionErrors
=
new
Mat
();
ArrayList
<
Mat
>
objectPoints
=
new
ArrayList
<
Mat
>();
ArrayList
<
Mat
>
objectPoints
=
new
ArrayList
<>();
objectPoints
.
add
(
Mat
.
zeros
(
mCornersSize
,
1
,
CvType
.
CV_32FC3
));
calcBoardCornerPositions
(
objectPoints
.
get
(
0
));
for
(
int
i
=
1
;
i
<
mCornersBuffer
.
size
();
i
++)
{
...
...
@@ -81,7 +81,7 @@ public class CameraCalibrator {
private
void
calcBoardCornerPositions
(
Mat
corners
)
{
final
int
cn
=
3
;
float
positions
[]
=
new
float
[
mCornersSize
*
cn
];
float
[]
positions
=
new
float
[
mCornersSize
*
cn
];
for
(
int
i
=
0
;
i
<
mPatternSize
.
height
;
i
++)
{
for
(
int
j
=
0
;
j
<
mPatternSize
.
width
*
cn
;
j
+=
cn
)
{
...
...
@@ -101,7 +101,7 @@ public class CameraCalibrator {
MatOfPoint2f
cornersProjected
=
new
MatOfPoint2f
();
double
totalError
=
0
;
double
error
;
float
viewErrors
[]
=
new
float
[
objectPoints
.
size
()];
float
[]
viewErrors
=
new
float
[
objectPoints
.
size
()];
MatOfDouble
distortionCoefficients
=
new
MatOfDouble
(
mDistortionCoefficients
);
int
totalPoints
=
0
;
...
...
Write
Preview
Markdown
is supported
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