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
eaf75dbc
Commit
eaf75dbc
authored
Aug 23, 2012
by
Andrey Kamaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix crash on resume in face detection sample
parent
c9d078ab
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
3 deletions
+20
-3
DetectionBasedTracker_jni.cpp
.../android/face-detection/jni/DetectionBasedTracker_jni.cpp
+18
-2
SampleCvViewBase.java
...detection/src/org/opencv/samples/fd/SampleCvViewBase.java
+2
-1
No files found.
samples/android/face-detection/jni/DetectionBasedTracker_jni.cpp
View file @
eaf75dbc
...
...
@@ -21,6 +21,7 @@ inline void vector_Rect_to_Mat(vector<Rect>& v_rect, Mat& mat)
JNIEXPORT
jlong
JNICALL
Java_org_opencv_samples_fd_DetectionBasedTracker_nativeCreateObject
(
JNIEnv
*
jenv
,
jclass
,
jstring
jFileName
,
jint
faceSize
)
{
LOGD
(
"Java_org_opencv_samples_fd_DetectionBasedTracker_nativeCreateObject enter"
);
const
char
*
jnamestr
=
jenv
->
GetStringUTFChars
(
jFileName
,
NULL
);
string
stdFileName
(
jnamestr
);
jlong
result
=
0
;
...
...
@@ -48,16 +49,21 @@ JNIEXPORT jlong JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeC
return
0
;
}
LOGD
(
"Java_org_opencv_samples_fd_DetectionBasedTracker_nativeCreateObject exit"
);
return
result
;
}
JNIEXPORT
void
JNICALL
Java_org_opencv_samples_fd_DetectionBasedTracker_nativeDestroyObject
(
JNIEnv
*
jenv
,
jclass
,
jlong
thiz
)
{
LOGD
(
"Java_org_opencv_samples_fd_DetectionBasedTracker_nativeDestroyObject enter"
);
try
{
((
DetectionBasedTracker
*
)
thiz
)
->
stop
();
delete
(
DetectionBasedTracker
*
)
thiz
;
if
(
thiz
!=
0
)
{
((
DetectionBasedTracker
*
)
thiz
)
->
stop
();
delete
(
DetectionBasedTracker
*
)
thiz
;
}
}
catch
(
cv
::
Exception
e
)
{
...
...
@@ -73,11 +79,13 @@ JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeDe
jclass
je
=
jenv
->
FindClass
(
"java/lang/Exception"
);
jenv
->
ThrowNew
(
je
,
"Unknown exception in JNI code {highgui::VideoCapture_n_1VideoCapture__()}"
);
}
LOGD
(
"Java_org_opencv_samples_fd_DetectionBasedTracker_nativeDestroyObject exit"
);
}
JNIEXPORT
void
JNICALL
Java_org_opencv_samples_fd_DetectionBasedTracker_nativeStart
(
JNIEnv
*
jenv
,
jclass
,
jlong
thiz
)
{
LOGD
(
"Java_org_opencv_samples_fd_DetectionBasedTracker_nativeStart enter"
);
try
{
((
DetectionBasedTracker
*
)
thiz
)
->
run
();
...
...
@@ -96,11 +104,13 @@ JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeSt
jclass
je
=
jenv
->
FindClass
(
"java/lang/Exception"
);
jenv
->
ThrowNew
(
je
,
"Unknown exception in JNI code {highgui::VideoCapture_n_1VideoCapture__()}"
);
}
LOGD
(
"Java_org_opencv_samples_fd_DetectionBasedTracker_nativeStart exit"
);
}
JNIEXPORT
void
JNICALL
Java_org_opencv_samples_fd_DetectionBasedTracker_nativeStop
(
JNIEnv
*
jenv
,
jclass
,
jlong
thiz
)
{
LOGD
(
"Java_org_opencv_samples_fd_DetectionBasedTracker_nativeStop enter"
);
try
{
((
DetectionBasedTracker
*
)
thiz
)
->
stop
();
...
...
@@ -119,11 +129,13 @@ JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeSt
jclass
je
=
jenv
->
FindClass
(
"java/lang/Exception"
);
jenv
->
ThrowNew
(
je
,
"Unknown exception in JNI code {highgui::VideoCapture_n_1VideoCapture__()}"
);
}
LOGD
(
"Java_org_opencv_samples_fd_DetectionBasedTracker_nativeStop exit"
);
}
JNIEXPORT
void
JNICALL
Java_org_opencv_samples_fd_DetectionBasedTracker_nativeSetFaceSize
(
JNIEnv
*
jenv
,
jclass
,
jlong
thiz
,
jint
faceSize
)
{
LOGD
(
"Java_org_opencv_samples_fd_DetectionBasedTracker_nativeSetFaceSize enter"
);
try
{
if
(
faceSize
>
0
)
...
...
@@ -148,12 +160,14 @@ JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeSe
jclass
je
=
jenv
->
FindClass
(
"java/lang/Exception"
);
jenv
->
ThrowNew
(
je
,
"Unknown exception in JNI code {highgui::VideoCapture_n_1VideoCapture__()}"
);
}
LOGD
(
"Java_org_opencv_samples_fd_DetectionBasedTracker_nativeSetFaceSize exit"
);
}
JNIEXPORT
void
JNICALL
Java_org_opencv_samples_fd_DetectionBasedTracker_nativeDetect
(
JNIEnv
*
jenv
,
jclass
,
jlong
thiz
,
jlong
imageGray
,
jlong
faces
)
{
LOGD
(
"Java_org_opencv_samples_fd_DetectionBasedTracker_nativeDetect enter"
);
try
{
vector
<
Rect
>
RectFaces
;
...
...
@@ -175,4 +189,5 @@ JNIEXPORT void JNICALL Java_org_opencv_samples_fd_DetectionBasedTracker_nativeDe
jclass
je
=
jenv
->
FindClass
(
"java/lang/Exception"
);
jenv
->
ThrowNew
(
je
,
"Unknown exception in JNI code {highgui::VideoCapture_n_1VideoCapture__()}"
);
}
LOGD
(
"Java_org_opencv_samples_fd_DetectionBasedTracker_nativeDetect exit"
);
}
\ No newline at end of file
samples/android/face-detection/src/org/opencv/samples/fd/SampleCvViewBase.java
View file @
eaf75dbc
...
...
@@ -34,8 +34,8 @@ public abstract class SampleCvViewBase extends SurfaceView implements SurfaceHol
releaseCamera
();
mCamera
=
new
VideoCapture
(
Highgui
.
CV_CAP_ANDROID
);
if
(!
mCamera
.
isOpened
())
{
releaseCamera
();
Log
.
e
(
TAG
,
"Failed to open native camera"
);
releaseCamera
();
return
false
;
}
}
...
...
@@ -92,6 +92,7 @@ public abstract class SampleCvViewBase extends SurfaceView implements SurfaceHol
public
void
surfaceDestroyed
(
SurfaceHolder
holder
)
{
Log
.
i
(
TAG
,
"surfaceDestroyed"
);
releaseCamera
();
Log
.
i
(
TAG
,
"surfaceDestroyed2"
);
}
protected
abstract
Bitmap
processFrame
(
VideoCapture
capture
);
...
...
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