diff --git a/model_zoo/official/lite/Himindspore/app/build.gradle b/model_zoo/official/lite/Himindspore/app/build.gradle index c7c010d7524..b37220a2383 100644 --- a/model_zoo/official/lite/Himindspore/app/build.gradle +++ b/model_zoo/official/lite/Himindspore/app/build.gradle @@ -8,22 +8,16 @@ android { applicationId "com.mindspore.himindspore" minSdkVersion 21 targetSdkVersion 30 - versionCode 1 - versionName "1.0" + versionCode 2 + versionName "1.1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" - externalNativeBuild { - cmake { - arguments "-DANDROID_STL=c++_shared" - cppFlags "-std=c++17" + javaCompileOptions { + annotationProcessorOptions { + arguments = [moduleName: project.getName()] } } - ndk { - abiFilters 'arm64-v8a' - } - } - aaptOptions { - noCompress '.so', 'ms' + } buildTypes { @@ -32,48 +26,28 @@ android { proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } - customDebugType { - debuggable true - } } - externalNativeBuild { - cmake { - path file('CMakeLists.txt') - } - } - ndkVersion '21.3.6528147' - sourceSets{ - main { - jniLibs.srcDirs = ['libs'] - } - } - packagingOptions{ - pickFirst 'lib/arm64-v8a/libmlkit-label-MS.so' + aaptOptions { + noCompress "ms" } + compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } } -// Before gradle build. -// To download some necessary libraries. -apply from:'download.gradle' - dependencies { implementation fileTree(dir: "libs", include: ["*.jar"]) implementation 'androidx.appcompat:appcompat:1.2.0' - implementation 'androidx.constraintlayout:constraintlayout:2.0.2' + implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'androidx.cardview:cardview:1.0.0' testImplementation 'junit:junit:4.13.1' androidTestImplementation 'androidx.test.ext:junit:1.1.2' androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' - implementation 'com.sun.mail:android-mail:1.6.5' - implementation 'com.sun.mail:android-activation:1.6.5' - implementation 'com.trello.rxlifecycle2:rxlifecycle:2.2.2' implementation 'com.trello.rxlifecycle2:rxlifecycle-components:2.2.2' @@ -85,4 +59,11 @@ dependencies { implementation 'com.squareup.okhttp3:logging-interceptor:4.9.0' implementation 'org.greenrobot:eventbus:3.0.0' + + implementation 'com.alibaba:arouter-api:1.2.1' + annotationProcessor 'com.alibaba:arouter-compiler:1.1.2' + + implementation project(':posenet') + implementation project(':imageObject') + implementation project(':styletransfer') } diff --git a/model_zoo/official/lite/Himindspore/app/src/androidTest/java/com/mindspore/himindspore/ExampleInstrumentedTest.java b/model_zoo/official/lite/Himindspore/app/src/androidTest/java/com/mindspore/himindspore/ExampleInstrumentedTest.java index 41ef62a8127..840c4d2eb47 100644 --- a/model_zoo/official/lite/Himindspore/app/src/androidTest/java/com/mindspore/himindspore/ExampleInstrumentedTest.java +++ b/model_zoo/official/lite/Himindspore/app/src/androidTest/java/com/mindspore/himindspore/ExampleInstrumentedTest.java @@ -2,13 +2,13 @@ package com.mindspore.himindspore; import android.content.Context; -import androidx.test.platform.app.InstrumentationRegistry; import androidx.test.ext.junit.runners.AndroidJUnit4; +import androidx.test.platform.app.InstrumentationRegistry; import org.junit.Test; import org.junit.runner.RunWith; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; /** * Instrumented test, which will execute on an Android device. diff --git a/model_zoo/official/lite/Himindspore/app/src/main/AndroidManifest.xml b/model_zoo/official/lite/Himindspore/app/src/main/AndroidManifest.xml index 29d4ed7091c..089d4e1c711 100644 --- a/model_zoo/official/lite/Himindspore/app/src/main/AndroidManifest.xml +++ b/model_zoo/official/lite/Himindspore/app/src/main/AndroidManifest.xml @@ -14,6 +14,7 @@ - - - - - - -#include -#include -#include -#include -#include -#include -#include -#include "include/errorcode.h" -#include "include/ms_tensor.h" -#include "MSNetWork.h" -#include "ssd_util/ssd_util.h" -#include "lite_cv/lite_mat.h" -#include "lite_cv/image_process.h" - -using mindspore::dataset::LiteMat; -using mindspore::dataset::LPixelType; -using mindspore::dataset::LDataType; -#define MS_PRINT(format, ...) __android_log_print(ANDROID_LOG_INFO, "MSJNI", format, ##__VA_ARGS__) - -bool ObjectBitmapToLiteMat(JNIEnv *env, const jobject &srcBitmap, LiteMat *lite_mat) { - bool ret = false; - AndroidBitmapInfo info; - void *pixels = nullptr; - LiteMat &lite_mat_bgr = *lite_mat; - AndroidBitmap_getInfo(env, srcBitmap, &info); - if (info.format != ANDROID_BITMAP_FORMAT_RGBA_8888) { - MS_PRINT("Image Err, Request RGBA"); - return false; - } - AndroidBitmap_lockPixels(env, srcBitmap, &pixels); - if (info.stride == info.width * 4) { - ret = InitFromPixel(reinterpret_cast(pixels), - LPixelType::RGBA2RGB, LDataType::UINT8, - info.width, info.height, lite_mat_bgr); - if (!ret) { - MS_PRINT("Init From RGBA error"); - } - } else { - unsigned char *pixels_ptr = new unsigned char[info.width * info.height * 4]; - unsigned char *ptr = pixels_ptr; - unsigned char *data = reinterpret_cast(pixels); - for (int i = 0; i < info.height; i++) { - memcpy(ptr, data, info.width * 4); - ptr += info.width * 4; - data += info.stride; - } - ret = InitFromPixel(reinterpret_cast(pixels_ptr), - LPixelType::RGBA2RGB, LDataType::UINT8, - info.width, info.height, lite_mat_bgr); - if (!ret) { - MS_PRINT("Init From RGBA error"); - } - delete[] (pixels_ptr); - } - AndroidBitmap_unlockPixels(env, srcBitmap); - return ret; -} - -bool ObjectPreProcessImageData(const LiteMat &lite_mat_bgr, LiteMat *lite_norm_mat_ptr) { - bool ret = false; - LiteMat lite_mat_resize; - LiteMat &lite_norm_mat_cut = *lite_norm_mat_ptr; - ret = ResizeBilinear(lite_mat_bgr, lite_mat_resize, 300, 300); - if (!ret) { - MS_PRINT("ResizeBilinear error"); - return false; - } - LiteMat lite_mat_convert_float; - ret = ConvertTo(lite_mat_resize, lite_mat_convert_float, 1.0 / 255.0); - if (!ret) { - MS_PRINT("ConvertTo error"); - return false; - } - - std::vector means = {0.485, 0.456, 0.406}; - std::vector stds = {0.229, 0.224, 0.225}; - SubStractMeanNormalize(lite_mat_convert_float, lite_norm_mat_cut, means, stds); - return true; -} - -char *ObjectCreateLocalModelBuffer(JNIEnv *env, jobject modelBuffer) { - jbyte *modelAddr = static_cast(env->GetDirectBufferAddress(modelBuffer)); - int modelLen = static_cast(env->GetDirectBufferCapacity(modelBuffer)); - char *buffer(new char[modelLen]); - memcpy(buffer, modelAddr, modelLen); - return buffer; -} - -/** - * - * @param msOutputs Model output, the mindspore inferencing result. - * @param srcImageWidth The width of the original input image. - * @param srcImageHeight The height of the original input image. - * @return - */ -std::string ProcessRunnetResult(std::unordered_map msOutputs, - int srcImageWidth, int srcImageHeight) { - std::unordered_map::iterator iter; - iter = msOutputs.begin(); - auto branch2_string = iter->first; - auto branch2_tensor = iter->second; - - ++iter; - auto branch1_string = iter->first; - auto branch1_tensor = iter->second; - MS_PRINT("%s %s", branch1_string.c_str(), branch2_string.c_str()); - - // ----------- 接口测试 -------------------------- - float *tmpscores2 = reinterpret_cast(branch1_tensor->MutableData()); - float *tmpdata = reinterpret_cast(branch2_tensor->MutableData()); - - // Using ssd model util to process model branch outputs. - SSDModelUtil ssdUtil(srcImageWidth, srcImageHeight); - - std::string retStr = ssdUtil.getDecodeResult(tmpscores2, tmpdata); - MS_PRINT("retStr %s", retStr.c_str()); - - return retStr; -} - -extern "C" JNIEXPORT jlong JNICALL -Java_com_mindspore_himindspore_objectdetection_help_ObjectTrackingMobile_loadModel(JNIEnv *env, jobject thiz, - jobject assetManager, - jobject buffer, - jint numThread) { - MS_PRINT("MindSpore so version 20200730"); - if (nullptr == buffer) { - MS_PRINT("error, buffer is nullptr!"); - return (jlong) nullptr; - } - jlong bufferLen = env->GetDirectBufferCapacity(buffer); - MS_PRINT("MindSpore get bufferLen:%d", static_cast(bufferLen)); - if (0 == bufferLen) { - MS_PRINT("error, bufferLen is 0!"); - return (jlong) nullptr; - } - - char *modelBuffer = ObjectCreateLocalModelBuffer(env, buffer); - if (modelBuffer == nullptr) { - MS_PRINT("modelBuffer create failed!"); - return (jlong) nullptr; - } - - MS_PRINT("MindSpore loading Model."); - void **labelEnv = new void *; - MSNetWork *labelNet = new MSNetWork; - *labelEnv = labelNet; - - mindspore::lite::Context *context = new mindspore::lite::Context; - context->thread_num_ = numThread; - - labelNet->CreateSessionMS(modelBuffer, bufferLen, context); - delete context; - if (labelNet->session() == nullptr) { - delete labelNet; - delete labelEnv; - MS_PRINT("MindSpore create session failed!."); - return (jlong) nullptr; - } - MS_PRINT("MindSpore create session successfully."); - - if (buffer != nullptr) { - env->DeleteLocalRef(buffer); - } - - if (assetManager != nullptr) { - env->DeleteLocalRef(assetManager); - } - MS_PRINT("ptr released successfully."); - - return (jlong) labelEnv; -} - - -extern "C" JNIEXPORT jstring JNICALL -Java_com_mindspore_himindspore_objectdetection_help_ObjectTrackingMobile_runNet(JNIEnv *env, jobject thiz, - jlong netEnv, - jobject srcBitmap) { - LiteMat lite_mat_bgr, lite_norm_mat_cut; - - if (!ObjectBitmapToLiteMat(env, srcBitmap, &lite_mat_bgr)) { - MS_PRINT("ObjectBitmapToLiteMat error"); - return NULL; - } - int srcImageWidth = lite_mat_bgr.width_; - int srcImageHeight = lite_mat_bgr.height_; - if (!ObjectPreProcessImageData(lite_mat_bgr, &lite_norm_mat_cut)) { - MS_PRINT("ObjectPreProcessImageData error"); - return NULL; - } - - ImgDims inputDims; - inputDims.channel = lite_norm_mat_cut.channel_; - inputDims.width = lite_norm_mat_cut.width_; - inputDims.height = lite_norm_mat_cut.height_; - - // Get the mindsore inference environment which created in loadModel(). - void **labelEnv = reinterpret_cast(netEnv); - if (labelEnv == nullptr) { - MS_PRINT("MindSpore error, labelEnv is a nullptr."); - return NULL; - } - MSNetWork *labelNet = static_cast(*labelEnv); - - auto mSession = labelNet->session(); - if (mSession == nullptr) { - MS_PRINT("MindSpore error, Session is a nullptr."); - return NULL; - } - MS_PRINT("MindSpore get session."); - - auto msInputs = mSession->GetInputs(); - auto inTensor = msInputs.front(); - float *dataHWC = reinterpret_cast(lite_norm_mat_cut.data_ptr_); - // copy input Tensor - memcpy(inTensor->MutableData(), dataHWC, - inputDims.channel * inputDims.width * inputDims.height * sizeof(float)); - MS_PRINT("MindSpore get msInputs."); - - auto status = mSession->RunGraph(); - if (status != mindspore::lite::RET_OK) { - MS_PRINT("MindSpore runnet error."); - return NULL; - } - - auto names = mSession->GetOutputTensorNames(); - std::unordered_map msOutputs; - for (const auto &name : names) { - auto temp_dat = mSession->GetOutputByTensorName(name); - msOutputs.insert(std::pair {name, temp_dat}); - } - std::string retStr = ProcessRunnetResult(msOutputs, srcImageWidth, srcImageHeight); - const char *resultChardata = retStr.c_str(); - - return (env)->NewStringUTF(resultChardata); -} - - -extern "C" -JNIEXPORT jboolean JNICALL -Java_com_mindspore_himindspore_objectdetection_help_ObjectTrackingMobile_unloadModel(JNIEnv *env, - jobject thiz, - jlong netEnv) { - void **labelEnv = reinterpret_cast(netEnv); - MSNetWork *labelNet = static_cast(*labelEnv); - labelNet->ReleaseNets(); - return (jboolean) true; -} - diff --git a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/SplashActivity.java b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/SplashActivity.java index 0cd742dac07..0899de37c4f 100644 --- a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/SplashActivity.java +++ b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/SplashActivity.java @@ -1,3 +1,18 @@ +/** + * Copyright 2020 Huawei Technologies Co., Ltd + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.mindspore.himindspore; import android.Manifest; @@ -11,7 +26,7 @@ import android.os.Build; import android.os.Environment; import android.util.Log; import android.view.View; -import android.widget.Button; +import android.widget.TextView; import android.widget.Toast; import androidx.annotation.NonNull; @@ -19,25 +34,27 @@ import androidx.appcompat.app.AlertDialog; import androidx.core.app.ActivityCompat; import androidx.core.content.FileProvider; +import com.alibaba.android.arouter.facade.annotation.Route; +import com.alibaba.android.arouter.launcher.ARouter; import com.mindspore.himindspore.base.BaseActivity; -import com.mindspore.himindspore.imageclassification.ui.ImageMainActivity; import com.mindspore.himindspore.mvp.MainContract; import com.mindspore.himindspore.mvp.MainPresenter; import com.mindspore.himindspore.net.FileDownLoadObserver; import com.mindspore.himindspore.net.UpdateInfoBean; -import com.mindspore.himindspore.objectdetection.ui.ObjectDetectionMainActivity; import java.io.File; -public class SplashActivity extends BaseActivity implements MainContract.View, View.OnClickListener { +@Route(path = "/himindspore/SplashActivity") +public class SplashActivity extends BaseActivity implements MainContract.View { private static final String TAG = "SplashActivity"; private static final int REQUEST_PERMISSION = 1; - private Button btnImage, btnObject, btnContract, btnAdvice; private boolean isHasPermssion; + private int now_version; private ProgressDialog progressDialog; + private TextView versionText; private static final String CODE_URL = "https://gitee.com/mindspore/mindspore/tree/master/model_zoo/official/lite"; private static final String HELP_URL = "https://github.com/mindspore-ai/mindspore/issues"; @@ -46,17 +63,8 @@ public class SplashActivity extends BaseActivity implements MainC @Override protected void init() { presenter = new MainPresenter(this); - - btnImage = findViewById(R.id.btn_image); - btnObject = findViewById(R.id.btn_object); - btnContract = findViewById(R.id.btn_contact); - btnAdvice = findViewById(R.id.btn_advice); - - btnImage.setOnClickListener(this); - btnObject.setOnClickListener(this); - btnContract.setOnClickListener(this); - btnAdvice.setOnClickListener(this); - + versionText = findViewById(R.id.tv_vision); + showPackaeInfo(); requestPermissions(); getUpdateInfo(); } @@ -66,6 +74,18 @@ public class SplashActivity extends BaseActivity implements MainC return R.layout.activity_splash; } + private void showPackaeInfo() { + try { + PackageManager packageManager = this.getPackageManager(); + PackageInfo packageInfo = packageManager.getPackageInfo(this.getPackageName(), 0); + now_version = packageInfo.versionCode; + versionText.setText("Version: " + packageInfo.versionName); + } catch (PackageManager.NameNotFoundException e) { + e.printStackTrace(); + } + + } + private void requestPermissions() { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, @@ -87,27 +107,65 @@ public class SplashActivity extends BaseActivity implements MainC } - @Override - public void onClick(View view) { - if (R.id.btn_image == view.getId()) { - if (isHasPermssion) { - startActivity(new Intent(SplashActivity.this, ImageMainActivity.class)); - } else { - requestPermissions(); - } - } else if (R.id.btn_object == view.getId()) { - if (isHasPermssion) { - startActivity(new Intent(SplashActivity.this, ObjectDetectionMainActivity.class)); - } else { - requestPermissions(); - } - } else if (R.id.btn_contact == view.getId()) { - openBrowser(CODE_URL); - } else if (R.id.btn_advice == view.getId()) { - openBrowser(HELP_URL); + public void onClickImage(View view) { + if (isHasPermssion) { + ARouter.getInstance().build("/imageobject/ImageCameraActivity") + .withInt("OPEN_TYPE", 1).navigation(); + } else { + requestPermissions(); } } + public void onClickGarbage(View view) { + if (isHasPermssion) { + ARouter.getInstance().build("/imageobject/ImageCameraActivity") + .withInt("OPEN_TYPE", 2).navigation(); + } else { + requestPermissions(); + } + } + + public void onClickPhotoDetection(View view) { + if (isHasPermssion) { + ARouter.getInstance().build("/imageobject/ObjectPhotoActivity").navigation(); + } else { + requestPermissions(); + } + } + + public void onClickCameraDetection(View view) { + if (isHasPermssion) { + ARouter.getInstance().build("/imageobject/ObjectCameraActivity").navigation(); + } else { + requestPermissions(); + } + } + + public void onClickPoseNet(View view) { + if (isHasPermssion) { + ARouter.getInstance().build("/posenet/PosenetMainActivity").navigation(this); + } else { + requestPermissions(); + } + } + + public void onClickStyleTransfer(View view) { + if (isHasPermssion) { + ARouter.getInstance().build("/styletransfer/StyleMainActivity").navigation(this); + } else { + requestPermissions(); + } + } + + public void onClickSouceCode(View view) { + openBrowser(CODE_URL); + } + + public void onClickHelp(View view) { + openBrowser(HELP_URL); + } + + public void openBrowser(String url) { Intent intent = new Intent(); intent.setAction("android.intent.action.VIEW"); @@ -160,16 +218,7 @@ public class SplashActivity extends BaseActivity implements MainC } - private int now_version; - public void showUpdate(final UpdateInfoBean updateInfo) { - try { - PackageManager packageManager = this.getPackageManager(); - PackageInfo packageInfo = packageManager.getPackageInfo(this.getPackageName(), 0); - now_version = packageInfo.versionCode; - } catch (PackageManager.NameNotFoundException e) { - e.printStackTrace(); - } if (now_version == updateInfo.getVersionCode()) { Toast.makeText(this, "已经是最新版本", Toast.LENGTH_SHORT).show(); @@ -245,4 +294,5 @@ public class SplashActivity extends BaseActivity implements MainC return directoryPath; } + } \ No newline at end of file diff --git a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/base/BaseActivity.java b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/base/BaseActivity.java index 219ccea4d36..e7ad9d40567 100644 --- a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/base/BaseActivity.java +++ b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/base/BaseActivity.java @@ -1,3 +1,18 @@ +/** + * Copyright 2020 Huawei Technologies Co., Ltd + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.mindspore.himindspore.base; import android.app.Activity; diff --git a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/base/BasePresenter.java b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/base/BasePresenter.java index e1c2d841e91..f02b6501189 100644 --- a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/base/BasePresenter.java +++ b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/base/BasePresenter.java @@ -1,3 +1,18 @@ +/** + * Copyright 2020 Huawei Technologies Co., Ltd + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.mindspore.himindspore.base; public abstract class BasePresenter { diff --git a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/base/MyApplication.java b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/base/MyApplication.java new file mode 100644 index 00000000000..25f42a8279b --- /dev/null +++ b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/base/MyApplication.java @@ -0,0 +1,34 @@ +/** + * Copyright 2020 Huawei Technologies Co., Ltd + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.mindspore.himindspore.base; + +import android.app.Application; + +import com.alibaba.android.arouter.BuildConfig; +import com.alibaba.android.arouter.launcher.ARouter; + + +public class MyApplication extends Application { + @Override + public void onCreate() { + super.onCreate(); + if (BuildConfig.DEBUG) { + ARouter.openLog(); + ARouter.openDebug(); + } + ARouter.init(this); + } +} diff --git a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/base/TrackListener.java b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/base/TrackListener.java deleted file mode 100644 index 5b78ab01db5..00000000000 --- a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/base/TrackListener.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.mindspore.himindspore.base; - -public interface TrackListener { -} diff --git a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/imageclassification/ui/ImageMainActivity.java b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/imageclassification/ui/ImageMainActivity.java deleted file mode 100644 index f5a8e4e1e17..00000000000 --- a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/imageclassification/ui/ImageMainActivity.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.mindspore.himindspore.imageclassification.ui; - -import android.content.Intent; -import android.os.Bundle; -import android.view.View; - -import androidx.appcompat.app.AppCompatActivity; - -import com.mindspore.himindspore.R; - -public class ImageMainActivity extends AppCompatActivity { - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_image_main); - - - findViewById(R.id.btn_demo).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - Intent intent = new Intent(ImageMainActivity.this, ImageCameraActivity.class); - intent.putExtra(ImageCameraActivity.OPEN_TYPE, ImageCameraActivity.TYPE_DEMO); - startActivity(intent); - } - }); - - findViewById(R.id.btn_custom).setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - Intent intent = new Intent(ImageMainActivity.this, ImageCameraActivity.class); - intent.putExtra(ImageCameraActivity.OPEN_TYPE, ImageCameraActivity.TYPE_CUSTOM); - startActivity(intent); - } - }); - } -} \ No newline at end of file diff --git a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/mvp/MainContract.java b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/mvp/MainContract.java index ce91446ff7d..cd458e3e4e5 100644 --- a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/mvp/MainContract.java +++ b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/mvp/MainContract.java @@ -1,3 +1,18 @@ +/** + * Copyright 2020 Huawei Technologies Co., Ltd + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.mindspore.himindspore.mvp; import com.mindspore.himindspore.net.FileDownLoadObserver; diff --git a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/mvp/MainPresenter.java b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/mvp/MainPresenter.java index 36cb74f922a..3be6ba71917 100644 --- a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/mvp/MainPresenter.java +++ b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/mvp/MainPresenter.java @@ -1,4 +1,19 @@ package com.mindspore.himindspore.mvp; +/** + * Copyright 2020 Huawei Technologies Co., Ltd + *

+ * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + *

+ * http://www.apache.org/licenses/LICENSE-2.0 + *

+ * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ import android.util.Log; @@ -40,7 +55,7 @@ public class MainPresenter extends BasePresenter implements Main @Override public void onFailure(Call call, Throwable t) { - Log.e(TAG, "onFailure" + t.toString()); + Log.e(TAG, "onFailure>>>" + t.toString()); view.showFail(call.toString()); } }); diff --git a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/objectdetection/ui/ObjectDetectionMainActivity.java b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/objectdetection/ui/ObjectDetectionMainActivity.java deleted file mode 100644 index a0807e54a7f..00000000000 --- a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/objectdetection/ui/ObjectDetectionMainActivity.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.mindspore.himindspore.objectdetection.ui; - -import android.Manifest; -import android.content.Intent; -import android.os.Bundle; -import android.view.View; -import android.widget.Button; - -import androidx.annotation.NonNull; -import androidx.appcompat.app.AppCompatActivity; -import androidx.core.app.ActivityCompat; - -import com.mindspore.himindspore.R; - -public class ObjectDetectionMainActivity extends AppCompatActivity implements View.OnClickListener { - - private static final int REQUEST_CAMERA_PERMISSION = 2; - private static final int REQUEST_PHOTO_PERMISSION = 3; - - private Button btnPhoto, btnCamera; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_object_detection_main); - - btnPhoto = findViewById(R.id.btn_photo); - btnCamera = findViewById(R.id.btn_camera); - - btnPhoto.setOnClickListener(this); - btnCamera.setOnClickListener(this); - } - - - @Override - public void onClick(View view) { - if (R.id.btn_photo == view.getId()) { - ActivityCompat.requestPermissions(this, - new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, - Manifest.permission.READ_PHONE_STATE}, REQUEST_PHOTO_PERMISSION); - } else if (R.id.btn_camera == view.getId()) { - ActivityCompat.requestPermissions(this, - new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE, - Manifest.permission.READ_PHONE_STATE, Manifest.permission.CAMERA}, REQUEST_CAMERA_PERMISSION); - } - } - - /** - * Authority application result callback - */ - @Override - public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { - if (REQUEST_PHOTO_PERMISSION == requestCode) { - choosePhoto(); - } else if (REQUEST_CAMERA_PERMISSION == requestCode) { - chooseCamera(); - } - } - - - private void choosePhoto() { - Intent intent = new Intent(ObjectDetectionMainActivity.this, ObjectPhotoActivity.class); - startActivity(intent); - } - - private void chooseCamera() { - Intent intent = new Intent(ObjectDetectionMainActivity.this, ObjectCameraActivity.class); - startActivity(intent); - } -} - diff --git a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/track/TrackListener.java b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/track/TrackListener.java deleted file mode 100644 index f9697c3e997..00000000000 --- a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/track/TrackListener.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.mindspore.himindspore.track; - -public interface TrackListener { -} diff --git a/model_zoo/official/lite/Himindspore/app/src/main/res/drawable-xxhdpi/btn_audio.png b/model_zoo/official/lite/Himindspore/app/src/main/res/drawable-xxhdpi/btn_audio.png new file mode 100644 index 00000000000..45b1bd4ea27 Binary files /dev/null and b/model_zoo/official/lite/Himindspore/app/src/main/res/drawable-xxhdpi/btn_audio.png differ diff --git a/model_zoo/official/lite/Himindspore/app/src/main/res/drawable-xxhdpi/btn_code.png b/model_zoo/official/lite/Himindspore/app/src/main/res/drawable-xxhdpi/btn_code.png index 40eda4c16dc..c229406d80f 100644 Binary files a/model_zoo/official/lite/Himindspore/app/src/main/res/drawable-xxhdpi/btn_code.png and b/model_zoo/official/lite/Himindspore/app/src/main/res/drawable-xxhdpi/btn_code.png differ diff --git a/model_zoo/official/lite/Himindspore/app/src/main/res/drawable-xxhdpi/btn_commend.png b/model_zoo/official/lite/Himindspore/app/src/main/res/drawable-xxhdpi/btn_commend.png new file mode 100644 index 00000000000..b92cde0a790 Binary files /dev/null and b/model_zoo/official/lite/Himindspore/app/src/main/res/drawable-xxhdpi/btn_commend.png differ diff --git a/model_zoo/official/lite/Himindspore/app/src/main/res/drawable-xxhdpi/btn_help.png b/model_zoo/official/lite/Himindspore/app/src/main/res/drawable-xxhdpi/btn_help.png index 72612afbcc6..3065f4f0542 100644 Binary files a/model_zoo/official/lite/Himindspore/app/src/main/res/drawable-xxhdpi/btn_help.png and b/model_zoo/official/lite/Himindspore/app/src/main/res/drawable-xxhdpi/btn_help.png differ diff --git a/model_zoo/official/lite/Himindspore/app/src/main/res/drawable-xxhdpi/btn_image.png b/model_zoo/official/lite/Himindspore/app/src/main/res/drawable-xxhdpi/btn_image.png index 1f41411f51a..a5e78d02d27 100644 Binary files a/model_zoo/official/lite/Himindspore/app/src/main/res/drawable-xxhdpi/btn_image.png and b/model_zoo/official/lite/Himindspore/app/src/main/res/drawable-xxhdpi/btn_image.png differ diff --git a/model_zoo/official/lite/Himindspore/app/src/main/res/drawable-xxhdpi/btn_object.png b/model_zoo/official/lite/Himindspore/app/src/main/res/drawable-xxhdpi/btn_object.png index 52bc74717ad..5fce1480701 100644 Binary files a/model_zoo/official/lite/Himindspore/app/src/main/res/drawable-xxhdpi/btn_object.png and b/model_zoo/official/lite/Himindspore/app/src/main/res/drawable-xxhdpi/btn_object.png differ diff --git a/model_zoo/official/lite/Himindspore/app/src/main/res/drawable-xxhdpi/btn_other.png b/model_zoo/official/lite/Himindspore/app/src/main/res/drawable-xxhdpi/btn_other.png new file mode 100644 index 00000000000..924bfdbe115 Binary files /dev/null and b/model_zoo/official/lite/Himindspore/app/src/main/res/drawable-xxhdpi/btn_other.png differ diff --git a/model_zoo/official/lite/Himindspore/app/src/main/res/drawable-xxhdpi/btn_text.png b/model_zoo/official/lite/Himindspore/app/src/main/res/drawable-xxhdpi/btn_text.png new file mode 100644 index 00000000000..35f396e7c88 Binary files /dev/null and b/model_zoo/official/lite/Himindspore/app/src/main/res/drawable-xxhdpi/btn_text.png differ diff --git a/model_zoo/official/lite/Himindspore/app/src/main/res/drawable/btn_code.png b/model_zoo/official/lite/Himindspore/app/src/main/res/drawable/btn_code.png deleted file mode 100644 index 9ec5a41cf5b..00000000000 Binary files a/model_zoo/official/lite/Himindspore/app/src/main/res/drawable/btn_code.png and /dev/null differ diff --git a/model_zoo/official/lite/Himindspore/app/src/main/res/drawable/btn_help.png b/model_zoo/official/lite/Himindspore/app/src/main/res/drawable/btn_help.png deleted file mode 100644 index 67c28d7cb5d..00000000000 Binary files a/model_zoo/official/lite/Himindspore/app/src/main/res/drawable/btn_help.png and /dev/null differ diff --git a/model_zoo/official/lite/Himindspore/app/src/main/res/drawable/btn_image.png b/model_zoo/official/lite/Himindspore/app/src/main/res/drawable/btn_image.png deleted file mode 100644 index eb82c1ad465..00000000000 Binary files a/model_zoo/official/lite/Himindspore/app/src/main/res/drawable/btn_image.png and /dev/null differ diff --git a/model_zoo/official/lite/Himindspore/app/src/main/res/drawable/btn_object.png b/model_zoo/official/lite/Himindspore/app/src/main/res/drawable/btn_object.png deleted file mode 100644 index 94b8a7323bd..00000000000 Binary files a/model_zoo/official/lite/Himindspore/app/src/main/res/drawable/btn_object.png and /dev/null differ diff --git a/model_zoo/official/lite/Himindspore/app/src/main/res/layout/activity_contract.xml b/model_zoo/official/lite/Himindspore/app/src/main/res/layout/activity_contract.xml deleted file mode 100644 index f34a8c35db6..00000000000 --- a/model_zoo/official/lite/Himindspore/app/src/main/res/layout/activity_contract.xml +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - -