feat: 切换后端至PaddleOCR-NCNN,切换工程为CMake
1.项目后端整体迁移至PaddleOCR-NCNN算法,已通过基本的兼容性测试 2.工程改为使用CMake组织,后续为了更好地兼容第三方库,不再提供QMake工程 3.重整权利声明文件,重整代码工程,确保最小化侵权风险 Log: 切换后端至PaddleOCR-NCNN,切换工程为CMake Change-Id: I4d5d2c5d37505a4a24b389b1a4c5d12f17bfa38c
This commit is contained in:
6
3rdparty/opencv-4.5.4/samples/android/tutorial-3-cameracontrol/CMakeLists.txt
vendored
Normal file
6
3rdparty/opencv-4.5.4/samples/android/tutorial-3-cameracontrol/CMakeLists.txt
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
set(sample example-tutorial-3-cameracontrol)
|
||||
|
||||
add_android_project(${sample} "${CMAKE_CURRENT_SOURCE_DIR}" LIBRARY_DEPS "${OPENCV_ANDROID_LIB_DIR}" SDK_TARGET 11 "${ANDROID_SDK_TARGET}")
|
||||
if(TARGET ${sample})
|
||||
add_dependencies(opencv_android_examples ${sample})
|
||||
endif()
|
31
3rdparty/opencv-4.5.4/samples/android/tutorial-3-cameracontrol/build.gradle.in
vendored
Normal file
31
3rdparty/opencv-4.5.4/samples/android/tutorial-3-cameracontrol/build.gradle.in
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion @ANDROID_COMPILE_SDK_VERSION@
|
||||
defaultConfig {
|
||||
applicationId "org.opencv.samples.tutorial3"
|
||||
minSdkVersion @ANDROID_MIN_SDK_VERSION@
|
||||
targetSdkVersion @ANDROID_TARGET_SDK_VERSION@
|
||||
versionCode 301
|
||||
versionName "3.01"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
sourceSets {
|
||||
main {
|
||||
java.srcDirs = @ANDROID_SAMPLE_JAVA_PATH@
|
||||
aidl.srcDirs = @ANDROID_SAMPLE_JAVA_PATH@
|
||||
res.srcDirs = @ANDROID_SAMPLE_RES_PATH@
|
||||
manifest.srcFile '@ANDROID_SAMPLE_MANIFEST_PATH@'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
//implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
implementation project(':opencv')
|
||||
}
|
35
3rdparty/opencv-4.5.4/samples/android/tutorial-3-cameracontrol/gradle/AndroidManifest.xml
vendored
Normal file
35
3rdparty/opencv-4.5.4/samples/android/tutorial-3-cameracontrol/gradle/AndroidManifest.xml
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.opencv.samples.tutorial3"
|
||||
>
|
||||
|
||||
<application
|
||||
android:label="@string/app_name"
|
||||
android:icon="@drawable/icon">
|
||||
|
||||
<activity android:name="Tutorial3Activity"
|
||||
android:label="@string/app_name"
|
||||
android:screenOrientation="landscape"
|
||||
android:configChanges="keyboardHidden|orientation">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
<supports-screens android:resizeable="true"
|
||||
android:smallScreens="true"
|
||||
android:normalScreens="true"
|
||||
android:largeScreens="true"
|
||||
android:anyDensity="true" />
|
||||
|
||||
<uses-permission android:name="android.permission.CAMERA"/>
|
||||
|
||||
<uses-feature android:name="android.hardware.camera" android:required="false"/>
|
||||
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>
|
||||
<uses-feature android:name="android.hardware.camera.front" android:required="false"/>
|
||||
<uses-feature android:name="android.hardware.camera.front.autofocus" android:required="false"/>
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
|
||||
</manifest>
|
BIN
3rdparty/opencv-4.5.4/samples/android/tutorial-3-cameracontrol/res/drawable/icon.png
vendored
Normal file
BIN
3rdparty/opencv-4.5.4/samples/android/tutorial-3-cameracontrol/res/drawable/icon.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.0 KiB |
@ -0,0 +1,12 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<org.opencv.samples.tutorial3.Tutorial3View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"
|
||||
android:id="@+id/tutorial3_activity_java_surface_view" />
|
||||
|
||||
</LinearLayout>
|
4
3rdparty/opencv-4.5.4/samples/android/tutorial-3-cameracontrol/res/values/strings.xml
vendored
Normal file
4
3rdparty/opencv-4.5.4/samples/android/tutorial-3-cameracontrol/res/values/strings.xml
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">OCV T3 Camera Control</string>
|
||||
</resources>
|
@ -0,0 +1,202 @@
|
||||
package org.opencv.samples.tutorial3;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
import org.opencv.android.BaseLoaderCallback;
|
||||
import org.opencv.android.CameraActivity;
|
||||
import org.opencv.android.CameraBridgeViewBase;
|
||||
import org.opencv.android.CameraBridgeViewBase.CvCameraViewFrame;
|
||||
import org.opencv.android.LoaderCallbackInterface;
|
||||
import org.opencv.android.OpenCVLoader;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.android.CameraBridgeViewBase.CvCameraViewListener2;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.hardware.Camera.Size;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.SubMenu;
|
||||
import android.view.SurfaceView;
|
||||
import android.view.View;
|
||||
import android.view.View.OnTouchListener;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
public class Tutorial3Activity extends CameraActivity implements CvCameraViewListener2, OnTouchListener {
|
||||
private static final String TAG = "OCVSample::Activity";
|
||||
|
||||
private Tutorial3View mOpenCvCameraView;
|
||||
private List<Size> mResolutionList;
|
||||
private Menu mMenu;
|
||||
private boolean mCameraStarted = false;
|
||||
private boolean mMenuItemsCreated = false;
|
||||
private MenuItem[] mEffectMenuItems;
|
||||
private SubMenu mColorEffectsMenu;
|
||||
private MenuItem[] mResolutionMenuItems;
|
||||
private SubMenu mResolutionMenu;
|
||||
|
||||
private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
|
||||
@Override
|
||||
public void onManagerConnected(int status) {
|
||||
switch (status) {
|
||||
case LoaderCallbackInterface.SUCCESS:
|
||||
{
|
||||
Log.i(TAG, "OpenCV loaded successfully");
|
||||
mOpenCvCameraView.enableView();
|
||||
mOpenCvCameraView.setOnTouchListener(Tutorial3Activity.this);
|
||||
} break;
|
||||
default:
|
||||
{
|
||||
super.onManagerConnected(status);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public Tutorial3Activity() {
|
||||
Log.i(TAG, "Instantiated new " + this.getClass());
|
||||
}
|
||||
|
||||
/** Called when the activity is first created. */
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
Log.i(TAG, "called onCreate");
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
|
||||
setContentView(R.layout.tutorial3_surface_view);
|
||||
|
||||
mOpenCvCameraView = (Tutorial3View) findViewById(R.id.tutorial3_activity_java_surface_view);
|
||||
|
||||
mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
|
||||
|
||||
mOpenCvCameraView.setCvCameraViewListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause()
|
||||
{
|
||||
super.onPause();
|
||||
if (mOpenCvCameraView != null)
|
||||
mOpenCvCameraView.disableView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume()
|
||||
{
|
||||
super.onResume();
|
||||
if (!OpenCVLoader.initDebug()) {
|
||||
Log.d(TAG, "Internal OpenCV library not found. Using OpenCV Manager for initialization");
|
||||
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_3_0_0, this, mLoaderCallback);
|
||||
} else {
|
||||
Log.d(TAG, "OpenCV library found inside package. Using it!");
|
||||
mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<? extends CameraBridgeViewBase> getCameraViewList() {
|
||||
return Collections.singletonList(mOpenCvCameraView);
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (mOpenCvCameraView != null)
|
||||
mOpenCvCameraView.disableView();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCameraViewStarted(int width, int height) {
|
||||
mCameraStarted = true;
|
||||
setupMenuItems();
|
||||
}
|
||||
|
||||
public void onCameraViewStopped() {
|
||||
}
|
||||
|
||||
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
|
||||
return inputFrame.rgba();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCreateOptionsMenu(Menu menu) {
|
||||
mMenu = menu;
|
||||
setupMenuItems();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void setupMenuItems() {
|
||||
if (mMenu == null || !mCameraStarted || mMenuItemsCreated) {
|
||||
return;
|
||||
}
|
||||
List<String> effects = mOpenCvCameraView.getEffectList();
|
||||
|
||||
if (effects == null) {
|
||||
Log.e(TAG, "Color effects are not supported by device!");
|
||||
return;
|
||||
}
|
||||
|
||||
mColorEffectsMenu = mMenu.addSubMenu("Color Effect");
|
||||
mEffectMenuItems = new MenuItem[effects.size()];
|
||||
|
||||
int idx = 0;
|
||||
ListIterator<String> effectItr = effects.listIterator();
|
||||
for (String effect: effects) {
|
||||
mEffectMenuItems[idx] = mColorEffectsMenu.add(1, idx, Menu.NONE, effect);
|
||||
idx++;
|
||||
}
|
||||
|
||||
mResolutionMenu = mMenu.addSubMenu("Resolution");
|
||||
mResolutionList = mOpenCvCameraView.getResolutionList();
|
||||
mResolutionMenuItems = new MenuItem[mResolutionList.size()];
|
||||
|
||||
idx = 0;
|
||||
for (Size resolution: mResolutionList) {
|
||||
mResolutionMenuItems[idx] = mResolutionMenu.add(2, idx, Menu.NONE,
|
||||
Integer.valueOf(resolution.width).toString() + "x" + Integer.valueOf(resolution.height).toString());
|
||||
idx++;
|
||||
}
|
||||
mMenuItemsCreated = true;
|
||||
}
|
||||
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
Log.i(TAG, "called onOptionsItemSelected; selected item: " + item);
|
||||
if (item.getGroupId() == 1)
|
||||
{
|
||||
mOpenCvCameraView.setEffect((String) item.getTitle());
|
||||
Toast.makeText(this, mOpenCvCameraView.getEffect(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
else if (item.getGroupId() == 2)
|
||||
{
|
||||
int id = item.getItemId();
|
||||
Size resolution = mResolutionList.get(id);
|
||||
mOpenCvCameraView.setResolution(resolution);
|
||||
resolution = mOpenCvCameraView.getResolution();
|
||||
String caption = Integer.valueOf(resolution.width).toString() + "x" + Integer.valueOf(resolution.height).toString();
|
||||
Toast.makeText(this, caption, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
Log.i(TAG,"onTouch event");
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss");
|
||||
String currentDateandTime = sdf.format(new Date());
|
||||
String fileName = Environment.getExternalStorageDirectory().getPath() +
|
||||
"/sample_picture_" + currentDateandTime + ".jpg";
|
||||
mOpenCvCameraView.takePicture(fileName);
|
||||
Toast.makeText(this, fileName + " saved", Toast.LENGTH_SHORT).show();
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package org.opencv.samples.tutorial3;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.List;
|
||||
|
||||
import org.opencv.android.JavaCameraView;
|
||||
|
||||
import android.content.Context;
|
||||
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 implements PictureCallback {
|
||||
|
||||
private static final String TAG = "Sample::Tutorial3View";
|
||||
private String mPictureFileName;
|
||||
|
||||
public Tutorial3View(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public List<String> getEffectList() {
|
||||
return mCamera.getParameters().getSupportedColorEffects();
|
||||
}
|
||||
|
||||
public boolean isEffectSupported() {
|
||||
return (mCamera.getParameters().getColorEffect() != null);
|
||||
}
|
||||
|
||||
public String getEffect() {
|
||||
return mCamera.getParameters().getColorEffect();
|
||||
}
|
||||
|
||||
public void setEffect(String effect) {
|
||||
Camera.Parameters params = mCamera.getParameters();
|
||||
params.setColorEffect(effect);
|
||||
mCamera.setParameters(params);
|
||||
}
|
||||
|
||||
public List<Size> getResolutionList() {
|
||||
return mCamera.getParameters().getSupportedPreviewSizes();
|
||||
}
|
||||
|
||||
public void setResolution(Size resolution) {
|
||||
disconnectCamera();
|
||||
mMaxHeight = resolution.height;
|
||||
mMaxWidth = resolution.width;
|
||||
connectCamera(getWidth(), getHeight());
|
||||
}
|
||||
|
||||
public Size getResolution() {
|
||||
return mCamera.getParameters().getPreviewSize();
|
||||
}
|
||||
|
||||
public void takePicture(final String fileName) {
|
||||
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);
|
||||
|
||||
// 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