Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ChessTrack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Aylen Ricca
ChessTrack
Commits
d1f1fd11
Commit
d1f1fd11
authored
10 years ago
by
Aylen Ricca
Browse files
Options
Downloads
Patches
Plain Diff
on sample add to write img-clear board- & on android added debug to client from supressBackground
parent
e7898c04
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ProyectoAndroid/ChessTrack/src/uy/edu/fing/chesstrack/modulovision/imgproc/BackgroundSupress.java
+29
-6
29 additions, 6 deletions
...ng/chesstrack/modulovision/imgproc/BackgroundSupress.java
samples/SubsBackground.cpp
+13
-3
13 additions, 3 deletions
samples/SubsBackground.cpp
with
42 additions
and
9 deletions
ProyectoAndroid/ChessTrack/src/uy/edu/fing/chesstrack/modulovision/imgproc/BackgroundSupress.java
+
29
−
6
View file @
d1f1fd11
...
...
@@ -17,6 +17,7 @@ import org.opencv.video.BackgroundSubtractorMOG;
import
org.opencv.video.BackgroundSubtractorMOG2
;
import
org.opencv.imgproc.*
;
import
uy.edu.chesstrack.communication.Client
;
import
android.graphics.SumPathEffect
;
import
android.media.AudioManager
;
import
android.media.ToneGenerator
;
...
...
@@ -26,12 +27,16 @@ import android.util.Log;
public
class
BackgroundSupress
implements
ImgProcInterface
{
private
static
final
String
TAG
=
"CHESSTRACK::BackgroundSupress"
;
private
static
int
e
=
0
;
private
final
Mat
fgMaskMOG
;
private
final
Mat
fgMaskMOG2
;
private
Mat
fgMaskMOG2
;
private
final
Mat
morphKernel
;
private
final
BackgroundSubtractorMOG
pMOG
;
private
final
BackgroundSubtractorMOG2
pMOG2
;
private
final
List
<
MatOfPoint
>
contours
;
private
BackgroundSubtractorMOG2
pMOG2
;
//private final List<MatOfPoint> contours;
private
Client
communicator
;
private
int
estadoANTERIOR
=
0
;
private
int
estadoACTUAL
=
0
;
public
BackgroundSupress
()
{
super
();
...
...
@@ -41,7 +46,9 @@ public class BackgroundSupress implements ImgProcInterface {
pMOG
=
new
BackgroundSubtractorMOG
();
//MOG approach
pMOG2
=
new
BackgroundSubtractorMOG2
();
//MOG approach
Log
.
i
(
TAG
,
"at background supress constructor"
);
contours
=
new
ArrayList
<
MatOfPoint
>();
//contours = new ArrayList<MatOfPoint>();
communicator
=
Client
.
getInstance
();
}
@Override
...
...
@@ -62,8 +69,8 @@ public class BackgroundSupress implements ImgProcInterface {
Imgproc
.
threshold
(
fgMaskMOG2
,
fgMaskMOG2
,
200
,
255
,
Imgproc
.
THRESH_BINARY
);
Log
.
i
(
TAG
,
"Apply threshold"
);
Imgproc
.
dilate
(
fgMaskMOG2
,
fgMaskMOG2
,
morphKernel
);
Log
.
i
(
TAG
,
"Apply dilate"
);
//
Imgproc.dilate(fgMaskMOG2, fgMaskMOG2, morphKernel);
//
Log.i(TAG, "Apply dilate");
Scalar
suma
=
Core
.
sumElems
(
fgMaskMOG2
);
Log
.
i
(
TAG
,
"SUMA = "
+
suma
);
...
...
@@ -87,12 +94,28 @@ public class BackgroundSupress implements ImgProcInterface {
}*/
if
(
suma
.
val
[
0
]
>
100000
){
estadoANTERIOR
=
estadoACTUAL
;
estadoACTUAL
=
1
;
Log
.
i
(
TAG
,
"MANO !!!"
);
communicator
.
SendData
(
"1\n"
);
Core
.
putText
(
fgMaskMOG2
,
"MANO !!!"
,
new
Point
(
50
,
50
),
Core
.
FONT_HERSHEY_SIMPLEX
,
0.8
,
new
Scalar
(
255
,
255
,
0
));
// ToneGenerator toneG = new ToneGenerator(AudioManager.STREAM_ALARM, 50);
// toneG.startTone(ToneGenerator.TONE_CDMA_ALERT_CALL_GUARD, 200); // 200 is duration in ms
}
else
{
estadoANTERIOR
=
estadoACTUAL
;
if
(
estadoANTERIOR
==
1
){
// estado transicion
estadoACTUAL
=
3
;
}
if
(
estadoANTERIOR
==
3
){
// estado estable
estadoACTUAL
=
2
;
pMOG2
=
new
BackgroundSubtractorMOG2
();
//MOG2 approach
}
Log
.
i
(
TAG
,
"ESTABLE !!!"
);
communicator
.
SendData
(
"0\n"
);
Core
.
putText
(
fgMaskMOG2
,
"ESTABLE !!!"
,
new
Point
(
50
,
50
),
Core
.
FONT_HERSHEY_SIMPLEX
,
0.5
,
new
Scalar
(
255
,
255
,
0
));
}
...
...
This diff is collapsed.
Click to expand it.
samples/SubsBackground.cpp
+
13
−
3
View file @
d1f1fd11
...
...
@@ -66,7 +66,7 @@ int main(int argc, char* argv[])
//create GUI windows
namedWindow
(
"Frame"
);
namedWindow
(
"FG Mask MOG"
);
//
namedWindow("FG Mask MOG");
namedWindow
(
"FG Mask MOG 2"
);
//create Background Subtractor objects
...
...
@@ -99,6 +99,10 @@ int main(int argc, char* argv[])
void
processVideo
(
char
*
videoFilename
)
{
int
estadoANTERIOR
=
0
;
int
estadoACTUAL
=
0
;
int
c
=
0
;
char
buffer
[
15
];
//create the capture object
VideoCapture
capture
(
videoFilename
);
if
(
!
capture
.
isOpened
()){
...
...
@@ -142,7 +146,7 @@ void processVideo(char* videoFilename) {
// cerr << suma.val[0] << endl;
if
(
suma
.
val
[
0
]
>
1
00
0000
){
if
(
suma
.
val
[
0
]
>
1
25
0000
){
// estado oclusion
estadoANTERIOR
=
estadoACTUAL
;
estadoACTUAL
=
1
;
...
...
@@ -158,6 +162,12 @@ void processVideo(char* videoFilename) {
if
(
estadoANTERIOR
==
3
){
// estado estable
estadoACTUAL
=
2
;
imshow
(
"ESTABLE"
,
frame
);
int
b
=
sprintf
(
buffer
,
"tablero%d.png"
,
c
);
imwrite
(
buffer
,
frame
);
c
++
;
pMOG
=
new
BackgroundSubtractorMOG
();
//MOG approach
pMOG2
=
new
BackgroundSubtractorMOG2
();
//MOG2 approach
}
...
...
@@ -184,7 +194,7 @@ void processVideo(char* videoFilename) {
//show the current frame and the fg masks
imshow
(
"Frame"
,
frame
);
imshow
(
"FG Mask MOG"
,
fgMaskMOG
);
//
imshow("FG Mask MOG", fgMaskMOG);
imshow
(
"FG Mask MOG 2"
,
fgMaskMOG2
);
//get the input from the keyboard
keyboard
=
waitKey
(
30
);
...
...
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