Merge remote-tracking branch 'origin/2.4'
Conflicts: 3rdparty/libjasper/CMakeLists.txt cmake/OpenCVDetectOpenCL.cmake modules/calib3d/doc/camera_calibration_and_3d_reconstruction.rst modules/imgproc/src/floodfill.cpp modules/ocl/include/opencv2/ocl/ocl.hpp modules/ocl/src/arithm.cpp modules/ocl/src/haar.cpp modules/ocl/src/imgproc.cpp modules/ocl/src/initialization.cpp modules/ocl/src/matrix_operations.cpp modules/ocl/src/mcwutil.cpp modules/ocl/src/opencl/arithm_bitwise_and_mask.cl modules/ocl/src/opencl/arithm_bitwise_and_scalar_mask.cl modules/ocl/src/opencl/arithm_bitwise_binary_mask.cl modules/ocl/src/opencl/arithm_bitwise_binary_scalar.cl modules/ocl/src/opencl/arithm_bitwise_binary_scalar_mask.cl modules/ocl/src/opencl/arithm_bitwise_or.cl modules/ocl/src/opencl/arithm_bitwise_or_scalar.cl modules/ocl/src/opencl/arithm_bitwise_or_scalar_mask.cl modules/ocl/src/opencl/arithm_bitwise_xor.cl modules/ocl/src/opencl/arithm_bitwise_xor_mask.cl modules/ocl/src/opencl/arithm_bitwise_xor_scalar.cl modules/ocl/src/stereobm.cpp modules/ocl/test/precomp.hpp modules/python/src2/api modules/ts/src/ts_func.cpp samples/gpu/bgfg_segm.cpp
This commit is contained in:
@@ -10,16 +10,13 @@ add_subdirectory(15-puzzle)
|
||||
add_subdirectory(face-detection)
|
||||
add_subdirectory(image-manipulations)
|
||||
add_subdirectory(color-blob-detection)
|
||||
|
||||
if (ANDROID_NATIVE_API_LEVEL GREATER 8)
|
||||
add_subdirectory(native-activity)
|
||||
endif()
|
||||
|
||||
add_subdirectory(tutorial-1-camerapreview)
|
||||
add_subdirectory(tutorial-2-mixedprocessing)
|
||||
add_subdirectory(tutorial-3-cameracontrol)
|
||||
|
||||
#hello-android sample
|
||||
add_subdirectory(native-activity)
|
||||
|
||||
# hello-android sample
|
||||
if(HAVE_opencv_highgui)
|
||||
ocv_include_modules_recurse(opencv_highgui opencv_core)
|
||||
add_executable(hello-android hello-android/main.cpp)
|
||||
|
||||
@@ -6,7 +6,6 @@ import org.opencv.android.OpenCVLoader;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
public class CvNativeActivity extends Activity {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:opencv="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
@@ -20,4 +20,4 @@
|
||||
opencv:show_fps="true"
|
||||
opencv:camera_id="any" />
|
||||
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
|
||||
@@ -6,17 +6,16 @@ import java.util.List;
|
||||
import org.opencv.android.JavaCameraView;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.hardware.Camera;
|
||||
import android.hardware.Camera.PictureCallback;
|
||||
import android.hardware.Camera.Size;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Log;
|
||||
|
||||
public class Tutorial3View extends JavaCameraView {
|
||||
public class Tutorial3View extends JavaCameraView implements PictureCallback {
|
||||
|
||||
private static final String TAG = "Sample::Tutorial3View";
|
||||
private String mPictureFileName;
|
||||
|
||||
public Tutorial3View(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
@@ -56,26 +55,33 @@ public class Tutorial3View extends JavaCameraView {
|
||||
}
|
||||
|
||||
public void takePicture(final String fileName) {
|
||||
Log.i(TAG, "Tacking picture");
|
||||
PictureCallback callback = new PictureCallback() {
|
||||
Log.i(TAG, "Taking picture");
|
||||
this.mPictureFileName = fileName;
|
||||
// Postview and jpeg are sent in the same buffers if the queue is not empty when performing a capture.
|
||||
// Clear up buffers to avoid mCamera.takePicture to be stuck because of a memory issue
|
||||
mCamera.setPreviewCallback(null);
|
||||
|
||||
private String mPictureFileName = fileName;
|
||||
|
||||
@Override
|
||||
public void onPictureTaken(byte[] data, Camera camera) {
|
||||
Log.i(TAG, "Saving a bitmap to file");
|
||||
Bitmap picture = BitmapFactory.decodeByteArray(data, 0, data.length);
|
||||
try {
|
||||
FileOutputStream out = new FileOutputStream(mPictureFileName);
|
||||
picture.compress(Bitmap.CompressFormat.JPEG, 90, out);
|
||||
picture.recycle();
|
||||
mCamera.startPreview();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
mCamera.takePicture(null, null, callback);
|
||||
// PictureCallback is implemented by the current class
|
||||
mCamera.takePicture(null, null, this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPictureTaken(byte[] data, Camera camera) {
|
||||
Log.i(TAG, "Saving a bitmap to file");
|
||||
// The camera preview was automatically stopped. Start it again.
|
||||
mCamera.startPreview();
|
||||
mCamera.setPreviewCallback(this);
|
||||
|
||||
// Write the image in a file (in jpeg format)
|
||||
try {
|
||||
FileOutputStream fos = new FileOutputStream(mPictureFileName);
|
||||
|
||||
fos.write(data);
|
||||
fos.close();
|
||||
|
||||
} catch (java.io.IOException e) {
|
||||
Log.e("PictureDemo", "Exception in photoCallback", e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user