Skip to content

Commit

Permalink
HARDCODE: add point pass to CV function
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeniy Chormonov committed Nov 12, 2017
1 parent dc69838 commit 387016a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
18 changes: 15 additions & 3 deletions libuvccamera/src/main/jni/UVCCamera/UVCPreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ void UVCPreview::do_preview(uvc_stream_ctrl_t *ctrl) {
#endif
if (frameMode) {
// MJPEG mode
LOGW("@@@@@@@@@@@ MJPEG mode @@@@@@@@@@@@");
for ( ; LIKELY(isRunning()) ; ) {
frame_mjpeg = waitPreviewFrame();
if (LIKELY(frame_mjpeg)) {
Expand Down Expand Up @@ -746,6 +747,9 @@ void UVCPreview::clearCaptureFrame() {
pthread_mutex_unlock(&capture_mutex);
}

pass_2_cv_t UVCPreview::pass2Cv = NULL;


//======================================================================
/*
* thread function
Expand Down Expand Up @@ -782,11 +786,14 @@ void UVCPreview::do_capture(JNIEnv *env) {
callbackPixelFormatChanged();
for (; isRunning() ;) {
mIsCapturing = true;
#if 0
if (mCaptureWindow) {
do_capture_surface(env);
} else {
do_capture_idle_loop(env);
}
#endif
do_capture_idle_loop(env);
pthread_cond_broadcast(&capture_sync);
} // end of for (; isRunning() ;)
EXIT();
Expand All @@ -796,9 +803,14 @@ void UVCPreview::do_capture_idle_loop(JNIEnv *env) {
ENTER();

for (; isRunning() && isCapturing() ;) {
do_capture_callback(env, waitCaptureFrame());
}

//do_capture_callback(env, waitCaptureFrame());
uvc_frame_t *frame = waitCaptureFrame();
if(pass2Cv) {
pass2Cv(env, frame);
}
recycle_frame(frame);
}
pass2Cv = NULL;
EXIT();
}

Expand Down
11 changes: 11 additions & 0 deletions libuvccamera/src/main/jni/UVCCamera/UVCPreview.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@

typedef uvc_error_t (*convFunc_t)(uvc_frame_t *in, uvc_frame_t *out);

typedef void (*pass_2_cv_t)(JNIEnv *env, uvc_frame_t *in);

#define PIXEL_FORMAT_RAW 0 // same as PIXEL_FORMAT_YUV
#define PIXEL_FORMAT_YUV 1
#define PIXEL_FORMAT_RGB565 2
Expand Down Expand Up @@ -109,6 +111,9 @@ class UVCPreview {
void do_capture_idle_loop(JNIEnv *env);
void do_capture_callback(JNIEnv *env, uvc_frame_t *frame);
void callbackPixelFormatChanged();

static pass_2_cv_t pass2Cv;

public:
UVCPreview(uvc_device_handle_t *devh);
~UVCPreview();
Expand All @@ -121,6 +126,12 @@ class UVCPreview {
int stopPreview();
inline const bool isCapturing() const;
int setCaptureDisplay(ANativeWindow *capture_window);

static void setPass2cv(pass_2_cv_t point)
{
pass2Cv = point;
}

};

#endif /* UVCPREVIEW_H_ */

0 comments on commit 387016a

Please sign in to comment.