parent
95573571f0
commit
40dc0b32fc
@ -1,26 +0,0 @@
|
||||
package com.mindspore.himindspore;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
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.assertEquals;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
assertEquals("com.mindspore.himindspore", appContext.getPackageName());
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
plugins {
|
||||
id 'com.android.library'
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 30
|
||||
buildToolsVersion "30.0.1"
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 30
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
arguments = [AROUTER_MODULE_NAME: project.getName()]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
aaptOptions {
|
||||
noCompress "ms"
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
lintOptions {
|
||||
checkReleaseBuilds false
|
||||
// Or, if you prefer, you can continue to check for errors in release builds,
|
||||
// but continue the build even when errors are found:
|
||||
abortOnError false
|
||||
}
|
||||
|
||||
repositories {
|
||||
google()
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
maven { url "https://jitpack.io" }
|
||||
|
||||
flatDir {
|
||||
dirs 'libs', '../mindsporelibrary/libs'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
|
||||
apply from: 'download.gradle'
|
||||
|
||||
dependencies {
|
||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
|
||||
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
|
||||
implementation 'com.google.android.material:material:1.2.1'
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
|
||||
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
|
||||
implementation 'com.github.bumptech.glide:glide:4.11.0'
|
||||
annotationProcessor 'com.github.bumptech.glide:compiler:4.11.0'
|
||||
|
||||
implementation 'com.alibaba:arouter-api:1.5.1'
|
||||
annotationProcessor 'com.alibaba:arouter-compiler:1.5.1'
|
||||
implementation project(':mindsporelibrary')
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* To download necessary library from HuaWei server.
|
||||
* Including mindspore-lite .so file, minddata-lite .so file and model file.
|
||||
* The libraries can be downloaded manually.
|
||||
*/
|
||||
def targetModelFile = "src/main/assets/segment_model.ms"
|
||||
def modelDownloadUrl = "https://download.mindspore.cn/model_zoo/official/lite/mobile_segment_lite/segment_model.ms"
|
||||
|
||||
task downloadModelFile(type: DownloadUrlTask) {
|
||||
doFirst {
|
||||
println "Downloading ${modelDownloadUrl}"
|
||||
}
|
||||
sourceUrl = "${modelDownloadUrl}"
|
||||
target = file("${targetModelFile}")
|
||||
}
|
||||
|
||||
if (file("src/main/assets/segment_model.ms").exists()) {
|
||||
downloadModelFile.enabled = false
|
||||
}
|
||||
|
||||
preBuild.dependsOn downloadModelFile
|
||||
|
||||
class DownloadUrlTask extends DefaultTask {
|
||||
@Input
|
||||
String sourceUrl
|
||||
|
||||
@OutputFile
|
||||
File target
|
||||
|
||||
@TaskAction
|
||||
void download() {
|
||||
ant.get(src: sourceUrl, dest: target)
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.mindspore.imagesegmentation">
|
||||
|
||||
|
||||
<application
|
||||
tools:replace="android:label"
|
||||
android:allowBackup="true"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true">
|
||||
<activity android:name=".SegmentationMainActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.AppCompat.NoActionBar">
|
||||
</activity>
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="com.mindspore.imagesegmentation.fileprovider"
|
||||
android:exported="false"
|
||||
tools:replace="android:authorities"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
tools:replace="android:resource"
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths"/>
|
||||
</provider>
|
||||
</application>
|
||||
|
||||
</manifest>
|
@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* 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.imagesegmentation;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
public interface OnBackgroundImageListener {
|
||||
void onBackImageSelected(int position);
|
||||
|
||||
void onImageAdd(View view);
|
||||
|
||||
}
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,97 @@
|
||||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* 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.imagesegmentation;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
|
||||
public class StyleRecyclerViewAdapter extends RecyclerView.Adapter<StyleRecyclerViewAdapter.StyleItemViewHolder> {
|
||||
|
||||
private final int[] IMAGES;
|
||||
private final Context context;
|
||||
private final OnBackgroundImageListener mListener;
|
||||
|
||||
public StyleRecyclerViewAdapter(Context context, int[] IMAGES, OnBackgroundImageListener mListener) {
|
||||
this.IMAGES = IMAGES;
|
||||
this.context = context;
|
||||
this.mListener = mListener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public StyleItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(context)
|
||||
.inflate(R.layout.image_item, parent, false);
|
||||
return new StyleItemViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull StyleItemViewHolder holder, int position) {
|
||||
Glide.with(context).
|
||||
load(IMAGES[position]).
|
||||
into(holder.getImageView());
|
||||
|
||||
View view = holder.getMView();
|
||||
view.setTag(IMAGES[position]);
|
||||
view.setOnClickListener(view1 -> {
|
||||
if (mListener != null) {
|
||||
if (IMAGES.length - 1 == position) {
|
||||
mListener.onImageAdd(holder.getImageView());
|
||||
} else {
|
||||
mListener.onBackImageSelected(position);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return IMAGES == null ? 0 : IMAGES.length;
|
||||
}
|
||||
|
||||
|
||||
public class StyleItemViewHolder extends RecyclerView.ViewHolder {
|
||||
private ImageView imageView;
|
||||
private final View mView;
|
||||
|
||||
public final ImageView getImageView() {
|
||||
return this.imageView;
|
||||
}
|
||||
|
||||
public final void setImageView(ImageView imageView) {
|
||||
this.imageView = imageView;
|
||||
}
|
||||
|
||||
public final View getMView() {
|
||||
return this.mView;
|
||||
}
|
||||
|
||||
public StyleItemViewHolder(View mView) {
|
||||
super(mView);
|
||||
this.mView = mView;
|
||||
this.imageView = mView.findViewById(R.id.image_view);
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,81 @@
|
||||
/**
|
||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
||||
* <p>
|
||||
* 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
|
||||
* <p>
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* <p>
|
||||
* 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.imagesegmentation.help;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class ModelTrackingResult {
|
||||
private Bitmap bitmapResult;
|
||||
private Bitmap bitmapOriginal;
|
||||
private Bitmap bitmapMaskOnly;
|
||||
private String executionLog;
|
||||
private Set<Integer> itemsFound;
|
||||
|
||||
public ModelTrackingResult(Bitmap bitmapResult, Bitmap bitmapOriginal, Bitmap bitmapMaskOnly, String executionLog, Set<Integer> itemsFound) {
|
||||
this.bitmapResult = bitmapResult;
|
||||
this.bitmapOriginal = bitmapOriginal;
|
||||
this.bitmapMaskOnly = bitmapMaskOnly;
|
||||
this.executionLog = executionLog;
|
||||
this.itemsFound = itemsFound;
|
||||
}
|
||||
|
||||
public Bitmap getBitmapResult() {
|
||||
return bitmapResult;
|
||||
}
|
||||
|
||||
public ModelTrackingResult setBitmapResult(Bitmap bitmapResult) {
|
||||
this.bitmapResult = bitmapResult;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Bitmap getBitmapOriginal() {
|
||||
return bitmapOriginal;
|
||||
}
|
||||
|
||||
public ModelTrackingResult setBitmapOriginal(Bitmap bitmapOriginal) {
|
||||
this.bitmapOriginal = bitmapOriginal;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Bitmap getBitmapMaskOnly() {
|
||||
return bitmapMaskOnly;
|
||||
}
|
||||
|
||||
public ModelTrackingResult setBitmapMaskOnly(Bitmap bitmapMaskOnly) {
|
||||
this.bitmapMaskOnly = bitmapMaskOnly;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getExecutionLog() {
|
||||
return executionLog;
|
||||
}
|
||||
|
||||
public ModelTrackingResult setExecutionLog(String executionLog) {
|
||||
this.executionLog = executionLog;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Set<Integer> getItemsFound() {
|
||||
return itemsFound;
|
||||
}
|
||||
|
||||
public ModelTrackingResult setItemsFound(Set<Integer> itemsFound) {
|
||||
this.itemsFound = itemsFound;
|
||||
return this;
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:aapt="http://schemas.android.com/aapt"
|
||||
android:width="108dp"
|
||||
android:height="108dp"
|
||||
android:viewportWidth="108"
|
||||
android:viewportHeight="108">
|
||||
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
|
||||
<aapt:attr name="android:fillColor">
|
||||
<gradient
|
||||
android:endX="85.84757"
|
||||
android:endY="92.4963"
|
||||
android:startX="42.9492"
|
||||
android:startY="49.59793"
|
||||
android:type="linear">
|
||||
<item
|
||||
android:color="#44000000"
|
||||
android:offset="0.0" />
|
||||
<item
|
||||
android:color="#00000000"
|
||||
android:offset="1.0" />
|
||||
</gradient>
|
||||
</aapt:attr>
|
||||
</path>
|
||||
<path
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
|
||||
android:strokeWidth="1"
|
||||
android:strokeColor="#00000000" />
|
||||
</vector>
|
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 4.0 KiB |
After Width: | Height: | Size: 105 KiB |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue