From fee49b2aae0076c49a47df7764ea81febd650543 Mon Sep 17 00:00:00 2001 From: hukang hwx963878 Date: Tue, 3 Nov 2020 18:52:09 +0800 Subject: [PATCH] remove a lot of Chinese comments in the code --- .../main/cpp/GarbageMindSporeNetnative.cpp | 60 +- .../src/main/cpp/ImageMindSporeNetnative.cpp | 820 +++++++++--------- .../mindspore/himindspore/SplashActivity.java | 2 +- .../himindspore/camera/CameraPreview.java | 98 +-- .../contract/ContractActivity.java | 55 -- .../himindspore/contract/email/MailInfo.java | 109 --- .../contract/email/MailSender.java | 202 ----- .../contract/email/MyAuthenticator.java | 21 - .../contract/email/SendMailUtil.java | 51 -- .../help/ImageDegreeHelper.java | 185 ---- .../help/ObjectTrackingMobile.java | 39 +- .../ui/ObjectCameraActivity.java | 4 +- .../ui/ObjectDetectionMainActivity.java | 2 +- .../ui/ObjectPhotoActivity.java | 4 +- .../objectdetection/ui/ObjectRectView.java | 18 +- .../himindspore/utils/DisplayUtil.java | 18 +- .../app/src/main/cpp/MindSporeNetnative.cpp | 164 ++-- .../widget/AutoFitTextureView.java | 1 - .../widget/CameraFragment.java | 1 - .../mindspore/hiobject/SplashActivity.java | 12 +- .../hiobject/help/ImageDegreeHelper.java | 13 +- .../hiobject/help/TrackingMobile.java | 40 +- .../hiobject/objectdetect/CameraActivity.java | 6 +- .../objectdetect/DealDataActivity.java | 260 ------ .../hiobject/objectdetect/ObjectRectView.java | 17 +- .../hiobject/objectdetect/PhotoActivity.java | 2 +- 26 files changed, 641 insertions(+), 1563 deletions(-) delete mode 100644 model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/contract/ContractActivity.java delete mode 100644 model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/contract/email/MailInfo.java delete mode 100644 model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/contract/email/MailSender.java delete mode 100644 model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/contract/email/MyAuthenticator.java delete mode 100644 model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/contract/email/SendMailUtil.java delete mode 100644 model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/objectdetection/help/ImageDegreeHelper.java delete mode 100644 model_zoo/official/lite/object_detection/app/src/main/java/com/mindspore/hiobject/objectdetect/DealDataActivity.java diff --git a/model_zoo/official/lite/Himindspore/app/src/main/cpp/GarbageMindSporeNetnative.cpp b/model_zoo/official/lite/Himindspore/app/src/main/cpp/GarbageMindSporeNetnative.cpp index 1e6ae1e7612..d454acdfc6c 100644 --- a/model_zoo/official/lite/Himindspore/app/src/main/cpp/GarbageMindSporeNetnative.cpp +++ b/model_zoo/official/lite/Himindspore/app/src/main/cpp/GarbageMindSporeNetnative.cpp @@ -37,39 +37,39 @@ using mindspore::dataset::LDataType; static const int RET_GARBAGE_SORT_SUM = 4; -static const char *labels_name_grbage_sort_map[RET_GARBAGE_SORT_SUM] = {{"可回收物"}, - {"干垃圾"}, - {"有害垃圾"}, - {"湿垃圾"}}; +static const char *labels_name_grbage_sort_map[RET_GARBAGE_SORT_SUM] = {"可回收物", + "干垃圾", + "有害垃圾", + "湿垃圾"}; static const int RET_GARBAGE_DETAILED_SUM = 26; static const char *labels_name_grbage_detailed_map[RET_GARBAGE_DETAILED_SUM] = { - {"塑料瓶"}, - {"帽子"}, - {"报纸"}, - {"易拉罐"}, - {"玻璃制品"}, - {"玻璃瓶"}, - {"硬纸板"}, - {"篮球"}, - {"纸张"}, - {"金属制品"}, - {"一次性筷子"}, - {"打火机"}, - {"扫把"}, - {"旧镜子"}, - {"牙刷"}, - {"脏污衣服"}, - {"贝壳"}, - {"陶瓷碗"}, - {"油漆桶"}, - {"电池"}, - {"荧光灯"}, - {"药片胶囊"}, - {"橙皮"}, - {"菜叶"}, - {"蛋壳"}, - {"香蕉皮"}}; + "塑料瓶", + "帽子", + "报纸", + "易拉罐", + "玻璃制品", + "玻璃瓶", + "硬纸板", + "篮球", + "纸张", + "金属制品", + "一次性筷子", + "打火机", + "扫把", + "旧镜子", + "牙刷", + "脏污衣服", + "贝壳", + "陶瓷碗", + "油漆桶", + "电池", + "荧光灯", + "药片胶囊", + "橙皮", + "菜叶", + "蛋壳", + "香蕉皮"}; char *CreateLocalModelBuffer(JNIEnv *env, jobject modelBuffer) { diff --git a/model_zoo/official/lite/Himindspore/app/src/main/cpp/ImageMindSporeNetnative.cpp b/model_zoo/official/lite/Himindspore/app/src/main/cpp/ImageMindSporeNetnative.cpp index fcae6a938dc..c0ff59ae614 100644 --- a/model_zoo/official/lite/Himindspore/app/src/main/cpp/ImageMindSporeNetnative.cpp +++ b/model_zoo/official/lite/Himindspore/app/src/main/cpp/ImageMindSporeNetnative.cpp @@ -38,416 +38,416 @@ using mindspore::dataset::LDataType; static const int RET_CATEGORY_SUM = 410; static const char *labels_name_map[RET_CATEGORY_SUM] = { - {"Herd"}, - {"Safari"}, - {"Bangle"}, - {"Cushion"}, - {"Countertop"}, - {"Prom"}, - {"Branch"}, - {"Sports"}, - {"Sky"}, - {"Community"}, - {"Wheel"}, - {"Cola"}, - {"Tuxedo"}, - {"Flowerpot"}, - {"Team"}, - {"Computer"}, - {"Unicycle"}, - {"Brig"}, - {"Aerospace engineering"}, - {"Scuba diving"}, - {"Goggles"}, - {"Fruit"}, - {"Badminton"}, - {"Horse"}, - {"Sunglasses"}, - {"Fun"}, - {"Prairie"}, - {"Poster"}, - {"Flag"}, - {"Speedboat"}, - {"Eyelash"}, - {"Veil"}, - {"Mobile phone"}, - {"Wheelbarrow"}, - {"Saucer"}, - {"Leather"}, - {"Drawer"}, - {"Paper"}, - {"Pier"}, - {"Waterfowl"}, - {"Tights"}, - {"Rickshaw"}, - {"Vegetable"}, - {"Handrail"}, - {"Ice"}, - {"Metal"}, - {"Flower"}, - {"Wing"}, - {"Silverware"}, - {"Event"}, - {"Skyline"}, - {"Money"}, - {"Comics"}, - {"Handbag"}, - {"Porcelain"}, - {"Rodeo"}, - {"Curtain"}, - {"Tile"}, - {"Human mouth"}, - {"Army"}, - {"Menu"}, - {"Boat"}, - {"Snowboarding"}, - {"Cairn terrier"}, - {"Net"}, - {"Pasteles"}, - {"Cup"}, - {"Rugby"}, - {"Pho"}, - {"Cap"}, - {"Human hair"}, - {"Surfing"}, - {"Loveseat"}, - {"Museum"}, - {"Shipwreck"}, - {"Trunk (Tree)"}, - {"Plush"}, - {"Monochrome"}, - {"Volcano"}, - {"Rock"}, - {"Pillow"}, - {"Presentation"}, - {"Nebula"}, - {"Subwoofer"}, - {"Lake"}, - {"Sledding"}, - {"Bangs"}, - {"Tablecloth"}, - {"Necklace"}, - {"Swimwear"}, - {"Standing"}, - {"Jeans"}, - {"Carnival"}, - {"Softball"}, - {"Centrepiece"}, - {"Skateboarder"}, - {"Cake"}, - {"Dragon"}, - {"Aurora"}, - {"Skiing"}, - {"Bathroom"}, - {"Dog"}, - {"Needlework"}, - {"Umbrella"}, - {"Church"}, - {"Fire"}, - {"Piano"}, - {"Denim"}, - {"Bridle"}, - {"Cabinetry"}, - {"Lipstick"}, - {"Ring"}, - {"Television"}, - {"Roller"}, - {"Seal"}, - {"Concert"}, - {"Product"}, - {"News"}, - {"Fast food"}, - {"Horn (Animal)"}, - {"Tattoo"}, - {"Bird"}, - {"Bridegroom"}, - {"Love"}, - {"Helmet"}, - {"Dinosaur"}, - {"Icing"}, - {"Miniature"}, - {"Tire"}, - {"Toy"}, - {"Icicle"}, - {"Jacket"}, - {"Coffee"}, - {"Mosque"}, - {"Rowing"}, - {"Wetsuit"}, - {"Camping"}, - {"Underwater"}, - {"Christmas"}, - {"Gelato"}, - {"Whiteboard"}, - {"Field"}, - {"Ragdoll"}, - {"Construction"}, - {"Lampshade"}, - {"Palace"}, - {"Meal"}, - {"Factory"}, - {"Cage"}, - {"Clipper (Boat)"}, - {"Gymnastics"}, - {"Turtle"}, - {"Human foot"}, - {"Marriage"}, - {"Web page"}, - {"Human beard"}, - {"Fog"}, - {"Wool"}, - {"Cappuccino"}, - {"Lighthouse"}, - {"Lego"}, - {"Sparkler"}, - {"Sari"}, - {"Model"}, - {"Temple"}, - {"Beanie"}, - {"Building"}, - {"Waterfall"}, - {"Penguin"}, - {"Cave"}, - {"Stadium"}, - {"Smile"}, - {"Human hand"}, - {"Park"}, - {"Desk"}, - {"Shetland sheepdog"}, - {"Bar"}, - {"Eating"}, - {"Neon"}, - {"Dalmatian"}, - {"Crocodile"}, - {"Wakeboarding"}, - {"Longboard"}, - {"Road"}, - {"Race"}, - {"Kitchen"}, - {"Odometer"}, - {"Cliff"}, - {"Fiction"}, - {"School"}, - {"Interaction"}, - {"Bullfighting"}, - {"Boxer"}, - {"Gown"}, - {"Aquarium"}, - {"Superhero"}, - {"Pie"}, - {"Asphalt"}, - {"Surfboard"}, - {"Cheeseburger"}, - {"Screenshot"}, - {"Supper"}, - {"Laugh"}, - {"Lunch"}, - {"Party "}, - {"Glacier"}, - {"Bench"}, - {"Grandparent"}, - {"Sink"}, - {"Pomacentridae"}, - {"Blazer"}, - {"Brick"}, - {"Space"}, - {"Backpacking"}, - {"Stuffed toy"}, - {"Sushi"}, - {"Glitter"}, - {"Bonfire"}, - {"Castle"}, - {"Marathon"}, - {"Pizza"}, - {"Beach"}, - {"Human ear"}, - {"Racing"}, - {"Sitting"}, - {"Iceberg"}, - {"Shelf"}, - {"Vehicle"}, - {"Pop music"}, - {"Playground"}, - {"Clown"}, - {"Car"}, - {"Rein"}, - {"Fur"}, - {"Musician"}, - {"Casino"}, - {"Baby"}, - {"Alcohol"}, - {"Strap"}, - {"Reef"}, - {"Balloon"}, - {"Outerwear"}, - {"Cathedral"}, - {"Competition"}, - {"Joker"}, - {"Blackboard"}, - {"Bunk bed"}, - {"Bear"}, - {"Moon"}, - {"Archery"}, - {"Polo"}, - {"River"}, - {"Fishing"}, - {"Ferris wheel"}, - {"Mortarboard"}, - {"Bracelet"}, - {"Flesh"}, - {"Statue"}, - {"Farm"}, - {"Desert"}, - {"Chain"}, - {"Aircraft"}, - {"Textile"}, - {"Hot dog"}, - {"Knitting"}, - {"Singer"}, - {"Juice"}, - {"Circus"}, - {"Chair"}, - {"Musical instrument"}, - {"Room"}, - {"Crochet"}, - {"Sailboat"}, - {"Newspaper"}, - {"Santa claus"}, - {"Swamp"}, - {"Skyscraper"}, - {"Skin"}, - {"Rocket"}, - {"Aviation"}, - {"Airliner"}, - {"Garden"}, - {"Ruins"}, - {"Storm"}, - {"Glasses"}, - {"Balance"}, - {"Nail (Body part)"}, - {"Rainbow"}, - {"Soil "}, - {"Vacation "}, - {"Moustache"}, - {"Doily"}, - {"Food"}, - {"Bride "}, - {"Cattle"}, - {"Pocket"}, - {"Infrastructure"}, - {"Train"}, - {"Gerbil"}, - {"Fireworks"}, - {"Pet"}, - {"Dam"}, - {"Crew"}, - {"Couch"}, - {"Bathing"}, - {"Quilting"}, - {"Motorcycle"}, - {"Butterfly"}, - {"Sled"}, - {"Watercolor paint"}, - {"Rafting"}, - {"Monument"}, - {"Lightning"}, - {"Sunset"}, - {"Bumper"}, - {"Shoe"}, - {"Waterskiing"}, - {"Sneakers"}, - {"Tower"}, - {"Insect"}, - {"Pool"}, - {"Placemat"}, - {"Airplane"}, - {"Plant"}, - {"Jungle"}, - {"Armrest"}, - {"Duck"}, - {"Dress"}, - {"Tableware"}, - {"Petal"}, - {"Bus"}, - {"Hanukkah"}, - {"Forest"}, - {"Hat"}, - {"Barn"}, - {"Tubing"}, - {"Snorkeling"}, - {"Cool"}, - {"Cookware and bakeware"}, - {"Cycling"}, - {"Swing (Seat)"}, - {"Muscle"}, - {"Cat"}, - {"Skateboard"}, - {"Star"}, - {"Toe"}, - {"Junk"}, - {"Bicycle"}, - {"Bedroom"}, - {"Person"}, - {"Sand"}, - {"Canyon"}, - {"Tie"}, - {"Twig"}, - {"Sphynx"}, - {"Supervillain"}, - {"Nightclub"}, - {"Ranch"}, - {"Pattern"}, - {"Shorts"}, - {"Himalayan"}, - {"Wall"}, - {"Leggings"}, - {"Windsurfing"}, - {"Deejay"}, - {"Dance"}, - {"Van"}, - {"Bento"}, - {"Sleep"}, - {"Wine"}, - {"Picnic"}, - {"Leisure"}, - {"Dune"}, - {"Crowd"}, - {"Kayak"}, - {"Ballroom"}, - {"Selfie"}, - {"Graduation"}, - {"Frigate"}, - {"Mountain"}, - {"Dude"}, - {"Windshield"}, - {"Skiff"}, - {"Class"}, - {"Scarf"}, - {"Bull"}, - {"Soccer"}, - {"Bag"}, - {"Basset hound"}, - {"Tractor"}, - {"Swimming"}, - {"Running"}, - {"Track"}, - {"Helicopter"}, - {"Pitch"}, - {"Clock"}, - {"Song"}, - {"Jersey"}, - {"Stairs"}, - {"Flap"}, - {"Jewellery"}, - {"Bridge"}, - {"Cuisine"}, - {"Bread"}, - {"Caving"}, - {"Shell"}, - {"Wreath"}, - {"Roof"}, - {"Cookie"}, - {"Canoe"}}; + "Herd", + "Safari", + "Bangle", + "Cushion", + "Countertop", + "Prom", + "Branch", + "Sports", + "Sky", + "Community", + "Wheel", + "Cola", + "Tuxedo", + "Flowerpot", + "Team", + "Computer", + "Unicycle", + "Brig", + "Aerospace engineering", + "Scuba diving", + "Goggles", + "Fruit", + "Badminton", + "Horse", + "Sunglasses", + "Fun", + "Prairie", + "Poster", + "Flag", + "Speedboat", + "Eyelash", + "Veil", + "Mobile phone", + "Wheelbarrow", + "Saucer", + "Leather", + "Drawer", + "Paper", + "Pier", + "Waterfowl", + "Tights", + "Rickshaw", + "Vegetable", + "Handrail", + "Ice", + "Metal", + "Flower", + "Wing", + "Silverware", + "Event", + "Skyline", + "Money", + "Comics", + "Handbag", + "Porcelain", + "Rodeo", + "Curtain", + "Tile", + "Human mouth", + "Army", + "Menu", + "Boat", + "Snowboarding", + "Cairn terrier", + "Net", + "Pasteles", + "Cup", + "Rugby", + "Pho", + "Cap", + "Human hair", + "Surfing", + "Loveseat", + "Museum", + "Shipwreck", + "Trunk (Tree)", + "Plush", + "Monochrome", + "Volcano", + "Rock", + "Pillow", + "Presentation", + "Nebula", + "Subwoofer", + "Lake", + "Sledding", + "Bangs", + "Tablecloth", + "Necklace", + "Swimwear", + "Standing", + "Jeans", + "Carnival", + "Softball", + "Centrepiece", + "Skateboarder", + "Cake", + "Dragon", + "Aurora", + "Skiing", + "Bathroom", + "Dog", + "Needlework", + "Umbrella", + "Church", + "Fire", + "Piano", + "Denim", + "Bridle", + "Cabinetry", + "Lipstick", + "Ring", + "Television", + "Roller", + "Seal", + "Concert", + "Product", + "News", + "Fast food", + "Horn (Animal)", + "Tattoo", + "Bird", + "Bridegroom", + "Love", + "Helmet", + "Dinosaur", + "Icing", + "Miniature", + "Tire", + "Toy", + "Icicle", + "Jacket", + "Coffee", + "Mosque", + "Rowing", + "Wetsuit", + "Camping", + "Underwater", + "Christmas", + "Gelato", + "Whiteboard", + "Field", + "Ragdoll", + "Construction", + "Lampshade", + "Palace", + "Meal", + "Factory", + "Cage", + "Clipper (Boat)", + "Gymnastics", + "Turtle", + "Human foot", + "Marriage", + "Web page", + "Human beard", + "Fog", + "Wool", + "Cappuccino", + "Lighthouse", + "Lego", + "Sparkler", + "Sari", + "Model", + "Temple", + "Beanie", + "Building", + "Waterfall", + "Penguin", + "Cave", + "Stadium", + "Smile", + "Human hand", + "Park", + "Desk", + "Shetland sheepdog", + "Bar", + "Eating", + "Neon", + "Dalmatian", + "Crocodile", + "Wakeboarding", + "Longboard", + "Road", + "Race", + "Kitchen", + "Odometer", + "Cliff", + "Fiction", + "School", + "Interaction", + "Bullfighting", + "Boxer", + "Gown", + "Aquarium", + "Superhero", + "Pie", + "Asphalt", + "Surfboard", + "Cheeseburger", + "Screenshot", + "Supper", + "Laugh", + "Lunch", + "Party ", + "Glacier", + "Bench", + "Grandparent", + "Sink", + "Pomacentridae", + "Blazer", + "Brick", + "Space", + "Backpacking", + "Stuffed toy", + "Sushi", + "Glitter", + "Bonfire", + "Castle", + "Marathon", + "Pizza", + "Beach", + "Human ear", + "Racing", + "Sitting", + "Iceberg", + "Shelf", + "Vehicle", + "Pop music", + "Playground", + "Clown", + "Car", + "Rein", + "Fur", + "Musician", + "Casino", + "Baby", + "Alcohol", + "Strap", + "Reef", + "Balloon", + "Outerwear", + "Cathedral", + "Competition", + "Joker", + "Blackboard", + "Bunk bed", + "Bear", + "Moon", + "Archery", + "Polo", + "River", + "Fishing", + "Ferris wheel", + "Mortarboard", + "Bracelet", + "Flesh", + "Statue", + "Farm", + "Desert", + "Chain", + "Aircraft", + "Textile", + "Hot dog", + "Knitting", + "Singer", + "Juice", + "Circus", + "Chair", + "Musical instrument", + "Room", + "Crochet", + "Sailboat", + "Newspaper", + "Santa claus", + "Swamp", + "Skyscraper", + "Skin", + "Rocket", + "Aviation", + "Airliner", + "Garden", + "Ruins", + "Storm", + "Glasses", + "Balance", + "Nail (Body part)", + "Rainbow", + "Soil ", + "Vacation ", + "Moustache", + "Doily", + "Food", + "Bride ", + "Cattle", + "Pocket", + "Infrastructure", + "Train", + "Gerbil", + "Fireworks", + "Pet", + "Dam", + "Crew", + "Couch", + "Bathing", + "Quilting", + "Motorcycle", + "Butterfly", + "Sled", + "Watercolor paint", + "Rafting", + "Monument", + "Lightning", + "Sunset", + "Bumper", + "Shoe", + "Waterskiing", + "Sneakers", + "Tower", + "Insect", + "Pool", + "Placemat", + "Airplane", + "Plant", + "Jungle", + "Armrest", + "Duck", + "Dress", + "Tableware", + "Petal", + "Bus", + "Hanukkah", + "Forest", + "Hat", + "Barn", + "Tubing", + "Snorkeling", + "Cool", + "Cookware and bakeware", + "Cycling", + "Swing (Seat)", + "Muscle", + "Cat", + "Skateboard", + "Star", + "Toe", + "Junk", + "Bicycle", + "Bedroom", + "Person", + "Sand", + "Canyon", + "Tie", + "Twig", + "Sphynx", + "Supervillain", + "Nightclub", + "Ranch", + "Pattern", + "Shorts", + "Himalayan", + "Wall", + "Leggings", + "Windsurfing", + "Deejay", + "Dance", + "Van", + "Bento", + "Sleep", + "Wine", + "Picnic", + "Leisure", + "Dune", + "Crowd", + "Kayak", + "Ballroom", + "Selfie", + "Graduation", + "Frigate", + "Mountain", + "Dude", + "Windshield", + "Skiff", + "Class", + "Scarf", + "Bull", + "Soccer", + "Bag", + "Basset hound", + "Tractor", + "Swimming", + "Running", + "Track", + "Helicopter", + "Pitch", + "Clock", + "Song", + "Jersey", + "Stairs", + "Flap", + "Jewellery", + "Bridge", + "Cuisine", + "Bread", + "Caving", + "Shell", + "Wreath", + "Roof", + "Cookie", + "Canoe"}; static float g_thres_map[RET_CATEGORY_SUM] = { 0.23, 0.03, 0.10, 0.13, 0.03, 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 142bf4bfafe..b5d264f4db1 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 @@ -50,7 +50,7 @@ public class SplashActivity extends AppCompatActivity implements View.OnClickLis } /** - * 权限申请结果回调 + * Authority application result callback */ @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { diff --git a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/camera/CameraPreview.java b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/camera/CameraPreview.java index bc788530544..38e868f857a 100644 --- a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/camera/CameraPreview.java +++ b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/camera/CameraPreview.java @@ -58,14 +58,14 @@ public class CameraPreview extends TextureView { private static final String TAG = "CameraPreview"; - private static final SparseIntArray ORIENTATIONS = new SparseIntArray();//从屏幕旋转转换为JPEG方向 - private static final int MAX_PREVIEW_WIDTH = 1920;//Camera2 API 保证的最大预览宽高 + private static final SparseIntArray ORIENTATIONS = new SparseIntArray();//From screen rotation to JPEG orientation + private static final int MAX_PREVIEW_WIDTH = 1920;//Camera2 API Guaranteed maximum preview width and height private static final int MAX_PREVIEW_HEIGHT = 1080; - private static final int STATE_PREVIEW = 0;//显示相机预览 - private static final int STATE_WAITING_LOCK = 1;//焦点锁定中 - private static final int STATE_WAITING_PRE_CAPTURE = 2;//拍照中 - private static final int STATE_WAITING_NON_PRE_CAPTURE = 3;//其它状态 - private static final int STATE_PICTURE_TAKEN = 4;//拍照完毕 + private static final int STATE_PREVIEW = 0;//Show camera preview + private static final int STATE_WAITING_LOCK = 1;//Focus locked + private static final int STATE_WAITING_PRE_CAPTURE = 2;//Taking pictures + private static final int STATE_WAITING_NON_PRE_CAPTURE = 3;//Other states + private static final int STATE_PICTURE_TAKEN = 4;//Photo finished public static final int OPEN_TYPE_IMAGE = 1; public static final int OPEN_TYPE_IMAGE_CUSTOM = 11; @@ -78,7 +78,7 @@ public class CameraPreview extends TextureView { private int mSensorOrientation; private boolean mFlashSupported; - private Semaphore mCameraOpenCloseLock = new Semaphore(1);//使用信号量 Semaphore 进行多线程任务调度 + private Semaphore mCameraOpenCloseLock = new Semaphore(1);//Multithreading task scheduling using Semaphore private Activity activity; private File mFile; private HandlerThread mBackgroundThread; @@ -153,7 +153,7 @@ public class CameraPreview extends TextureView { } /** - * 处理生命周期内的回调事件 + * Handle callback events in the lifecycle */ private final SurfaceTextureListener mSurfaceTextureListener = new SurfaceTextureListener() { @@ -178,14 +178,14 @@ public class CameraPreview extends TextureView { }; /** - * 相机状态改变回调 + * Camera state change callback */ private final CameraDevice.StateCallback mStateCallback = new CameraDevice.StateCallback() { @Override public void onOpened(@NonNull CameraDevice cameraDevice) { mCameraOpenCloseLock.release(); - Log.d(TAG, "相机已打开"); + Log.d(TAG, "open camera"); mCameraDevice = cameraDevice; createCameraPreviewSession(); } @@ -209,7 +209,7 @@ public class CameraPreview extends TextureView { }; /** - * 处理与照片捕获相关的事件 + * Handle events related to photo capture */ private CameraCaptureSession.CaptureCallback mCaptureCallback = new CameraCaptureSession.CaptureCallback() { @@ -289,7 +289,7 @@ public class CameraPreview extends TextureView { } } startBackgroundThread(); - //当Activity或Fragment OnResume()时,可以冲洗打开一个相机并开始预览,否则,这个Surface已经准备就绪 + //When activity or fragment onresume(), you can open a camera and start previewing, otherwise, the surface is ready if (this.isAvailable()) { openCamera(this.getWidth(), this.getHeight()); } else { @@ -396,7 +396,7 @@ public class CameraPreview extends TextureView { } /** - * 根据mCameraId打开相机 + * Turn on the camera according to the mcameraid */ private void openCamera(int width, int height) { setUpCameraOutputs(width, height); @@ -420,10 +420,10 @@ public class CameraPreview extends TextureView { } /** - * 设置相机相关的属性或变量 + * Set camera related properties or variables * - * @param width 相机预览的可用尺寸的宽度 - * @param height 相机预览的可用尺寸的高度 + * @param width The width of the available size for the camera preview + * @param height The height of the available size for the camera preview */ @SuppressWarnings("SuspiciousNameCombination") private void setUpCameraOutputs(int width, int height) { @@ -431,7 +431,7 @@ public class CameraPreview extends TextureView { try { for (String cameraId : manager.getCameraIdList()) { CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId); - // 在这个例子中不使用前置摄像头 + // In this example, the front camera is not used Integer facing = characteristics.get(CameraCharacteristics.LENS_FACING); if (facing != null && facing == CameraCharacteristics.LENS_FACING_FRONT) { continue; @@ -510,15 +510,15 @@ public class CameraPreview extends TextureView { } catch (CameraAccessException e) { e.printStackTrace(); } catch (NullPointerException e) { - Log.e(TAG, "设备不支持Camera2"); + Log.e(TAG, "Device not supported Camera2"); } } /** - * 在确定相机预览大小后应调用此方法 + * This method should be called after determining the camera preview size * - * @param viewWidth 宽 - * @param viewHeight 高 + * @param viewWidth width + * @param viewHeight height */ private void configureTransform(int viewWidth, int viewHeight) { if (null == mPreviewSize || null == activity) { @@ -546,15 +546,15 @@ public class CameraPreview extends TextureView { /** - * 获取一个合适的相机预览尺寸 + * Get a suitable camera preview size * - * @param choices 支持的预览尺寸列表 - * @param textureViewWidth 相对宽度 - * @param textureViewHeight 相对高度 - * @param maxWidth 可以选择的最大宽度 - * @param maxHeight 可以选择的最大高度 - * @param aspectRatio 宽高比 - * @return 最佳预览尺寸 + * @param choices List of supported preview sizes + * @param textureViewWidth Relative width + * @param textureViewHeight Relative height + * @param maxWidth Maximum width that can be selected + * @param maxHeight Maximum height that can be selected + * @param aspectRatio Aspect ratio + * @return Best preview size */ private static Size chooseOptimalSize(Size[] choices, int textureViewWidth, int textureViewHeight, int maxWidth, int maxHeight, Size aspectRatio) { @@ -584,18 +584,18 @@ public class CameraPreview extends TextureView { } /** - * 为相机预览创建新的CameraCaptureSession + * Create new for camera CameraCaptureSession */ private void createCameraPreviewSession() { try { SurfaceTexture texture = this.getSurfaceTexture(); assert texture != null; - // 将默认缓冲区的大小配置为想要的相机预览的大小 + // Configure the size of the default buffer to the size of the desired camera preview texture.setDefaultBufferSize(mPreviewSize.getWidth(), mPreviewSize.getHeight()); Surface surface = new Surface(texture); mPreviewRequestBuilder = mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW); mPreviewRequestBuilder.addTarget(surface); - // 我们创建一个 CameraCaptureSession 来进行相机预览 + // We create a camera capture session to preview the camera mCameraDevice.createCaptureSession(Arrays.asList(surface, mImageReader.getSurface()), new CameraCaptureSession.StateCallback() { @@ -604,7 +604,7 @@ public class CameraPreview extends TextureView { if (null == mCameraDevice) { return; } - // 会话准备好后,我们开始显示预览 + // When the session is ready, we begin to display the preview mCaptureSession = cameraCaptureSession; try { mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_MODE, @@ -628,23 +628,23 @@ public class CameraPreview extends TextureView { /** - * 从指定的屏幕旋转中检索照片方向 + * Retrieve the photo orientation from the specified screen rotation * - * @param rotation 屏幕方向 - * @return 照片方向(0,90,270,360) + * @param rotation Screen orientation + * @return Photo orientation(0,90,270,360) */ private int getOrientation(int rotation) { return (ORIENTATIONS.get(rotation) + mSensorOrientation + 270) % 360; } /** - * 锁定焦点 + * Lock focus */ private void lockFocus() { try { - // 如何通知相机锁定焦点 + // How to tell the camera to lock the focus mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AF_TRIGGER, CameraMetadata.CONTROL_AF_TRIGGER_START); - // 通知mCaptureCallback等待锁定 + // Inform mcapture callback to wait for lock mState = STATE_WAITING_LOCK; mCaptureSession.capture(mPreviewRequestBuilder.build(), mCaptureCallback, mBackgroundHandler); } catch (CameraAccessException e) { @@ -653,7 +653,7 @@ public class CameraPreview extends TextureView { } /** - * 解锁焦点 + * Unlock focus */ private void unlockFocus() { try { @@ -671,7 +671,7 @@ public class CameraPreview extends TextureView { } /** - * 拍摄静态图片 + * Take still pictures */ private void captureStillPicture() { try { @@ -684,7 +684,7 @@ public class CameraPreview extends TextureView { captureBuilder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE); setAutoFlash(captureBuilder); - // 方向 + // direction int rotation = activity.getWindowManager().getDefaultDisplay().getRotation(); captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, getOrientation(rotation)); CameraCaptureSession.CaptureCallback captureCallback @@ -725,11 +725,11 @@ public class CameraPreview extends TextureView { } /** - * 运行preCapture序列来捕获静止图像 + * Run the precapture sequence to capture still images */ private void runPreCaptureSequence() { try { - // 设置拍照参数请求 + // Set Photo parameter request mPreviewRequestBuilder.set(CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER, CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER_START); mState = STATE_WAITING_PRE_CAPTURE; @@ -740,7 +740,7 @@ public class CameraPreview extends TextureView { } /** - * 比较两者大小 + * Compare the size of the two */ private static class CompareSizesByArea implements Comparator { @@ -752,7 +752,7 @@ public class CameraPreview extends TextureView { } /** - * ImageReader的回调对象 + * Callback object for imagereader */ private final ImageReader.OnImageAvailableListener mOnImageAvailableListener = new ImageReader.OnImageAvailableListener() { @@ -764,7 +764,7 @@ public class CameraPreview extends TextureView { }; /** - * 将捕获到的图像保存到指定的文件中 + * Save the captured image to the specified file */ private static class ImageSaver implements Runnable { @@ -809,7 +809,7 @@ public class CameraPreview extends TextureView { } /** - * 关闭相机 + * closeCamera */ private void closeCamera() { try { diff --git a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/contract/ContractActivity.java b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/contract/ContractActivity.java deleted file mode 100644 index ca45154ed68..00000000000 --- a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/contract/ContractActivity.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.mindspore.himindspore.contract; - -import android.os.Bundle; -import android.text.TextUtils; -import android.view.View; -import android.widget.Button; -import android.widget.EditText; -import android.widget.Toast; - -import androidx.appcompat.app.AppCompatActivity; - -import com.mindspore.himindspore.R; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -public class ContractActivity extends AppCompatActivity implements View.OnClickListener { - - private EditText emailEdit; - private Button submitBtn; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_contract); - - emailEdit = findViewById(R.id.emailEditText); - submitBtn = findViewById(R.id.submitBtn); - submitBtn.setOnClickListener(this); - } - - @Override - public void onClick(View view) { - - if (R.id.submitBtn == view.getId()) { - String email = emailEdit.getText().toString(); - if (TextUtils.isEmpty(email)) { - Toast.makeText(ContractActivity.this,"Please input your email!",Toast.LENGTH_LONG).show(); - return; - } - if (isEmailFormat(email)){ - - }else{ - Toast.makeText(ContractActivity.this,"The email address you enterd is not in the correct format",Toast.LENGTH_LONG).show(); - return; - } - } - } - - private boolean isEmailFormat(String emailAdd) { - Pattern p = Pattern.compile("^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\\.([a-zA-Z0-9_-])+)+$"); - Matcher m = p.matcher(emailAdd); - return m.matches(); - } -} \ No newline at end of file diff --git a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/contract/email/MailInfo.java b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/contract/email/MailInfo.java deleted file mode 100644 index 08ea827270e..00000000000 --- a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/contract/email/MailInfo.java +++ /dev/null @@ -1,109 +0,0 @@ -package com.mindspore.himindspore.contract.email; - -import java.util.Properties; - -public class MailInfo { - - private String mailServerHost;// 发送邮件的服务器的IP - private String mailServerPort;// 发送邮件的服务器的端口 - private String fromAddress;// 邮件发送者的地址 - private String toAddress; // 邮件接收者的地址 - private String userName;// 登陆邮件发送服务器的用户名 - private String password;// 登陆邮件发送服务器的密码 - private boolean validate = true;// 是否需要身份验证 - private String subject;// 邮件主题 - private String content;// 邮件的文本内容 - private String[] attachFileNames;// 邮件附件的文件名 - - /** - * 获得邮件会话属性 - */ - public Properties getProperties() { - Properties p = new Properties(); - p.put("mail.smtp.host", this.mailServerHost); - p.put("mail.smtp.port", this.mailServerPort); - p.put("mail.smtp.auth", validate ? "true" : "false"); - return p; - } - - public String getMailServerHost() { - return mailServerHost; - } - - public void setMailServerHost(String mailServerHost) { - this.mailServerHost = mailServerHost; - } - - public String getMailServerPort() { - return mailServerPort; - } - - public void setMailServerPort(String mailServerPort) { - this.mailServerPort = mailServerPort; - } - - public boolean isValidate() { - return validate; - } - - public void setValidate(boolean validate) { - this.validate = validate; - } - - public String[] getAttachFileNames() { - return attachFileNames; - } - - public void setAttachFileNames(String[] fileNames) { - this.attachFileNames = fileNames; - } - - public String getFromAddress() { - return fromAddress; - } - - public void setFromAddress(String fromAddress) { - this.fromAddress = fromAddress; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getToAddress() { - return toAddress; - } - - public void setToAddress(String toAddress) { - this.toAddress = toAddress; - } - - public String getUserName() { - return userName; - } - - public void setUserName(String userName) { - this.userName = userName; - } - - public String getSubject() { - return subject; - } - - public void setSubject(String subject) { - this.subject = subject; - } - - public String getContent() { - return content; - } - - public void setContent(String textContent) { - this.content = textContent; - } - -} \ No newline at end of file diff --git a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/contract/email/MailSender.java b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/contract/email/MailSender.java deleted file mode 100644 index bf171edfd0e..00000000000 --- a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/contract/email/MailSender.java +++ /dev/null @@ -1,202 +0,0 @@ -package com.mindspore.himindspore.contract.email; - -import android.util.Log; - -import java.io.File; -import java.util.Date; -import java.util.Properties; - -import javax.activation.DataHandler; -import javax.activation.FileDataSource; -import javax.mail.Address; -import javax.mail.Authenticator; -import javax.mail.BodyPart; -import javax.mail.Message; -import javax.mail.MessagingException; -import javax.mail.Multipart; -import javax.mail.PasswordAuthentication; -import javax.mail.Session; -import javax.mail.Transport; -import javax.mail.internet.InternetAddress; -import javax.mail.internet.MimeBodyPart; -import javax.mail.internet.MimeMessage; -import javax.mail.internet.MimeMultipart; -import javax.mail.internet.MimeUtility; - -public class MailSender { - /** - * 以文本格式发送邮件 - * - * @param mailInfo 待发送的邮件的信息 - */ - public boolean sendTextMail(final MailInfo mailInfo) { - - // 判断是否需要身份认证 - MyAuthenticator authenticator = null; - Properties pro = mailInfo.getProperties(); - if (mailInfo.isValidate()) { - // 如果需要身份认证,则创建一个密码验证器 - authenticator = new MyAuthenticator(mailInfo.getUserName(), mailInfo.getPassword()); - } - // 根据邮件会话属性和密码验证器构造一个发送邮件的session - Session sendMailSession = Session.getDefaultInstance(pro, authenticator); - -// Session sendMailSession = Session.getInstance(pro, new Authenticator() { -// @Override -// protected PasswordAuthentication getPasswordAuthentication() { -// return new PasswordAuthentication(mailInfo.getUserName(),mailInfo.getPassword()); -// } -// }); - - try { - // 根据session创建一个邮件消息 - Message mailMessage = new MimeMessage(sendMailSession); - // 创建邮件发送者地址 - Address from = new InternetAddress(mailInfo.getFromAddress()); - // 设置邮件消息的发送者 - mailMessage.setFrom(from); - // 创建邮件的接收者地址,并设置到邮件消息中 - Address to = new InternetAddress(mailInfo.getToAddress()); - mailMessage.setRecipient(Message.RecipientType.TO, to); - // 设置邮件消息的主题 - mailMessage.setSubject(mailInfo.getSubject()); - // 设置邮件消息发送的时间 - mailMessage.setSentDate(new Date()); - - // 设置邮件消息的主要内容 - String mailContent = mailInfo.getContent(); - mailMessage.setText(mailContent); - // 发送邮件 - Transport.send(mailMessage); - return true; - } catch (MessagingException ex) { - ex.printStackTrace(); - } - return false; - } - - /** - * 以HTML格式发送邮件 - * - * @param mailInfo 待发送的邮件信息 - */ - public static boolean sendHtmlMail(MailInfo mailInfo) { - // 判断是否需要身份认证 - MyAuthenticator authenticator = null; - Properties pro = mailInfo.getProperties(); - // 如果需要身份认证,则创建一个密码验证器 - if (mailInfo.isValidate()) { - authenticator = new MyAuthenticator(mailInfo.getUserName(), mailInfo.getPassword()); - } - // 根据邮件会话属性和密码验证器构造一个发送邮件的session - Session sendMailSession = Session.getDefaultInstance(pro, authenticator); - try { - // 根据session创建一个邮件消息 - Message mailMessage = new MimeMessage(sendMailSession); - // 创建邮件发送者地址 - Address from = new InternetAddress(mailInfo.getFromAddress()); - // 设置邮件消息的发送者 - mailMessage.setFrom(from); - // 创建邮件的接收者地址,并设置到邮件消息中 - Address to = new InternetAddress(mailInfo.getToAddress()); - // Message.RecipientType.TO属性表示接收者的类型为TO - mailMessage.setRecipient(Message.RecipientType.TO, to); - // 设置邮件消息的主题 - mailMessage.setSubject(mailInfo.getSubject()); - // 设置邮件消息发送的时间 - mailMessage.setSentDate(new Date()); - // MiniMultipart类是一个容器类,包含MimeBodyPart类型的对象 - Multipart mainPart = new MimeMultipart(); - // 创建一个包含HTML内容的MimeBodyPart - BodyPart html = new MimeBodyPart(); - // 设置HTML内容 - html.setContent(mailInfo.getContent(), "text/html; charset=utf-8"); - mainPart.addBodyPart(html); - // 将MiniMultipart对象设置为邮件内容 - mailMessage.setContent(mainPart); - // 发送邮件 - Transport.send(mailMessage); - return true; - } catch (MessagingException ex) { - ex.printStackTrace(); - } - return false; - } - - - /** - * 发送带附件的邮件 - * - * @param info - * @return - */ - public boolean sendFileMail(MailInfo info, File file) { - Message attachmentMail = createAttachmentMail(info, file); - try { - Transport.send(attachmentMail); - return true; - } catch (MessagingException e) { - e.printStackTrace(); - return false; - } - - } - - /** - * 创建带有附件的邮件 - * - * @return - */ - private Message createAttachmentMail(final MailInfo info, File file) { - //创建邮件 - MimeMessage message = null; - Properties pro = info.getProperties(); - try { - - Session sendMailSession = Session.getInstance(pro, new Authenticator() { - @Override - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(info.getUserName(), info.getPassword()); - } - }); - - message = new MimeMessage(sendMailSession); - // 设置邮件的基本信息 - //创建邮件发送者地址 - Address from = new InternetAddress(info.getFromAddress()); - //设置邮件消息的发送者 - message.setFrom(from); - //创建邮件的接受者地址,并设置到邮件消息中 - Address to = new InternetAddress(info.getToAddress()); - //设置邮件消息的接受者, Message.RecipientType.TO属性表示接收者的类型为TO - message.setRecipient(Message.RecipientType.TO, to); - //邮件标题 - message.setSubject(info.getSubject()); - - // 创建邮件正文,为了避免邮件正文中文乱码问题,需要使用CharSet=UTF-8指明字符编码 - MimeBodyPart text = new MimeBodyPart(); - text.setContent(info.getContent(), "text/html;charset=UTF-8"); - - // 创建容器描述数据关系 - MimeMultipart mp = new MimeMultipart(); - mp.addBodyPart(text); - // 创建邮件附件 - MimeBodyPart attach = new MimeBodyPart(); - - FileDataSource ds = new FileDataSource(file); - DataHandler dh = new DataHandler(ds); - attach.setDataHandler(dh); - attach.setFileName(MimeUtility.encodeText(dh.getName())); - mp.addBodyPart(attach); - mp.setSubType("mixed"); - message.setContent(mp); - message.saveChanges(); - - } catch (Exception e) { - Log.i("TAG","创建带附件的邮件失败"); - e.printStackTrace(); - } - // 返回生成的邮件 - return message; - } -} diff --git a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/contract/email/MyAuthenticator.java b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/contract/email/MyAuthenticator.java deleted file mode 100644 index 05d14eeb283..00000000000 --- a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/contract/email/MyAuthenticator.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.mindspore.himindspore.contract.email; - -import javax.mail.Authenticator; -import javax.mail.PasswordAuthentication; - -public class MyAuthenticator extends Authenticator { - String userName = null; - String password = null; - - public MyAuthenticator() { - } - - public MyAuthenticator(String username, String password) { - this.userName = username; - this.password = password; - } - - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(userName, password); - } -} diff --git a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/contract/email/SendMailUtil.java b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/contract/email/SendMailUtil.java deleted file mode 100644 index 78b03224d6d..00000000000 --- a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/contract/email/SendMailUtil.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.mindspore.himindspore.contract.email; - -import androidx.annotation.NonNull; - -import java.io.File; - -public class SendMailUtil { - - public static void send(final File file, String toAdd) { - final MailInfo mailInfo = creatMail(toAdd); - final MailSender sms = new MailSender(); - new Thread(new Runnable() { - @Override - public void run() { - sms.sendFileMail(mailInfo, file); - } - }).start(); -} - - public static void send(String toAdd) { - final MailInfo mailInfo = creatMail(toAdd); - final MailSender sms = new MailSender(); - new Thread(new Runnable() { - @Override - public void run() { - sms.sendTextMail(mailInfo); - } - }).start(); - } - - @NonNull - private static MailInfo creatMail(String toAdd) { - -// String HOST = ShareUtils.getString(MyApplication.getInstance(), "HOST", ""); -// String PORT = ShareUtils.getString(MyApplication.getInstance(), "PORT", ""); -// String FROM_ADD = ShareUtils.getString(MyApplication.getInstance(), "FROM_ADD", ""); -// String FROM_PSW = ShareUtils.getString(MyApplication.getInstance(), "FROM_PSW", ""); - final MailInfo mailInfo = new MailInfo(); -// mailInfo.setMailServerHost(HOST);//发送方邮箱服务器 -// mailInfo.setMailServerPort(PORT);//发送方邮箱端口号 -// mailInfo.setValidate(true); -// mailInfo.setUserName(FROM_ADD); // 发送者邮箱地址 -// mailInfo.setPassword(FROM_PSW);// 发送者邮箱授权码 -// mailInfo.setFromAddress(FROM_ADD); // 发送者邮箱 -// mailInfo.setToAddress(toAdd); // 接收者邮箱 -// mailInfo.setSubject("Android应用测试"); // 邮件主题 -// mailInfo.setContent("哈哈"); // 邮件文本 - return mailInfo; - } - -} \ No newline at end of file diff --git a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/objectdetection/help/ImageDegreeHelper.java b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/objectdetection/help/ImageDegreeHelper.java deleted file mode 100644 index 67df17865e9..00000000000 --- a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/objectdetection/help/ImageDegreeHelper.java +++ /dev/null @@ -1,185 +0,0 @@ -package com.mindspore.himindspore.objectdetection.help; - -import android.annotation.SuppressLint; -import android.content.ContentUris; -import android.content.Context; -import android.database.Cursor; -import android.graphics.Bitmap; -import android.graphics.Matrix; -import android.media.ExifInterface; -import android.net.Uri; -import android.os.Build; -import android.os.Environment; -import android.provider.DocumentsContract; -import android.provider.MediaStore; - -import java.io.IOException; - -public class ImageDegreeHelper { - /** - * 专为Android4.4及以上设计的从Uri获取文件绝对路径,以前的方法已不好使 - */ - @SuppressLint("NewApi") - public static String getPath(final Context context, final Uri uri) { - - final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT; - - // DocumentProvider - if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) { - // ExternalStorageProvider - if (isExternalStorageDocument(uri)) { - final String docId = DocumentsContract.getDocumentId(uri); - final String[] split = docId.split(":"); - final String type = split[0]; - - if ("primary".equalsIgnoreCase(type)) { - return Environment.getExternalStorageDirectory() + "/" + split[1]; - } - - // TODO handle non-primary volumes - } - // DownloadsProvider - else if (isDownloadsDocument(uri)) { - - final String id = DocumentsContract.getDocumentId(uri); - final Uri contentUri = ContentUris.withAppendedId( - Uri.parse("content://downloads/public_downloads"), Long.valueOf(id)); - - return getDataColumn(context, contentUri, null, null); - } - // MediaProvider - else if (isMediaDocument(uri)) { - final String docId = DocumentsContract.getDocumentId(uri); - final String[] split = docId.split(":"); - final String type = split[0]; - - Uri contentUri = null; - if ("image".equals(type)) { - contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI; - } else if ("video".equals(type)) { - contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI; - } else if ("audio".equals(type)) { - contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI; - } - - final String selection = "_id=?"; - final String[] selectionArgs = new String[]{split[1]}; - - return getDataColumn(context, contentUri, selection, selectionArgs); - } - } - // MediaStore (and general) - else if ("content".equalsIgnoreCase(uri.getScheme())) { - return getDataColumn(context, uri, null, null); - } - // File - else if ("file".equalsIgnoreCase(uri.getScheme())) { - return uri.getPath(); - } - - return null; - } - - /** - * Get the value of the data column for this Uri. This is useful for - * MediaStore Uris, and other file-based ContentProviders. - * - * @param context The context. - * @param uri The Uri to query. - * @param selection (Optional) Filter used in the query. - * @param selectionArgs (Optional) Selection arguments used in the query. - * @return The value of the _data column, which is typically a file path. - */ - public static String getDataColumn(Context context, Uri uri, String selection, - String[] selectionArgs) { - - Cursor cursor = null; - final String column = "_data"; - final String[] projection = {column}; - - try { - cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, - null); - if (cursor != null && cursor.moveToFirst()) { - final int column_index = cursor.getColumnIndexOrThrow(column); - return cursor.getString(column_index); - } - } finally { - if (cursor != null) - cursor.close(); - } - return null; - } - - /** - * @param uri The Uri to check. - * @return Whether the Uri authority is ExternalStorageProvider. - */ - public static boolean isExternalStorageDocument(Uri uri) { - return "com.android.externalstorage.documents".equals(uri.getAuthority()); - } - - /** - * @param uri The Uri to check. - * @return Whether the Uri authority is DownloadsProvider. - */ - public static boolean isDownloadsDocument(Uri uri) { - return "com.android.providers.downloads.documents".equals(uri.getAuthority()); - } - - /** - * @param uri The Uri to check. - * @return Whether the Uri authority is MediaProvider. - */ - public static boolean isMediaDocument(Uri uri) { - return "com.android.providers.media.documents".equals(uri.getAuthority()); - } - - /** - * 读取照片旋转角度 - * - * @param path 照片路径 - * @return 角度 - */ - public static int readPictureDegree(String path) { - int degree = 0; - try { - ExifInterface exifInterface = new ExifInterface(path); - int orientation = exifInterface.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); - switch (orientation) { - case ExifInterface.ORIENTATION_ROTATE_90: - degree = 90; - break; - case ExifInterface.ORIENTATION_ROTATE_180: - degree = 180; - break; - case ExifInterface.ORIENTATION_ROTATE_270: - degree = 270; - break; - } - } catch (IOException e) { - e.printStackTrace(); - } - return degree; - } - - - public static Bitmap rotaingImageView(int angle, Bitmap bitmap) { - Bitmap returnBm = null; - // 根据旋转角度,生成旋转矩阵 - Matrix matrix = new Matrix(); - matrix.postRotate(angle); - try { - // 将原始图片按照旋转矩阵进行旋转,并得到新的图片 - returnBm = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); - } catch (OutOfMemoryError e) { - } - if (returnBm == null) { - returnBm = bitmap; - } - if (bitmap != returnBm) { - bitmap.recycle(); - } - return returnBm; - } -} diff --git a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/objectdetection/help/ObjectTrackingMobile.java b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/objectdetection/help/ObjectTrackingMobile.java index 2fe485b7462..8d0fa7cecda 100644 --- a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/objectdetection/help/ObjectTrackingMobile.java +++ b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/objectdetection/help/ObjectTrackingMobile.java @@ -37,40 +37,39 @@ public class ObjectTrackingMobile implements TrackListener { } /** - * jni加载模型 + * jni Load model * * @param assetManager assetManager * @param buffer buffer * @param numThread numThread - * @return 加载模型数据 + * @return Load model data */ public native long loadModel(AssetManager assetManager, ByteBuffer buffer, int numThread); /** - * jni运行模型 + * jni Run model * - * @param netEnv 加载模型数据 - * @param img 当前图片 - * @return 运行模型数据 + * @param netEnv Load model data + * @param img Current picture + * @return Run model data */ public native String runNet(long netEnv, Bitmap img); /** - * 解绑模型数据 + * Unbind model data * - * @param netEnv 模型数据 - * @return 解绑状态 + * @param netEnv model data + * @return Unbound state */ public native boolean unloadModel(long netEnv); /** - * C++侧封装成了MSNetWorks类的方法 + * C++ encapsulated as a method of the msnetworks class * - * @param assetManager 模型文件位置 - * @return 加载模型文件状态 + * @param assetManager Model file location + * @return Loading model file status */ public boolean loadModelFromBuf(AssetManager assetManager) { -// String ModelPath = "model/model_hebing_3branch.ms"; String ModelPath = "model/ssd.ms"; ByteBuffer buffer = loadModelFile(ModelPath); @@ -79,10 +78,10 @@ public class ObjectTrackingMobile implements TrackListener { } /** - * 运行Mindspore + * Run Mindspore * - * @param img 当前图片识别 - * @return 识别出来的文字信息 + * @param img Current image recognition + * @return Recognized text information */ public String MindSpore_runnet(Bitmap img) { String ret_str = runNet(netEnv, img); @@ -90,7 +89,7 @@ public class ObjectTrackingMobile implements TrackListener { } /** - * 解绑模型 + * Unbound model * @return true */ public boolean unloadModel() { @@ -99,9 +98,9 @@ public class ObjectTrackingMobile implements TrackListener { } /** - * 加载模型文件流 - * @param modelPath 模型文件路径 - * @return 加载模型文件流 + * Load model file stream + * @param modelPath Model file path + * @return Load model file stream */ public ByteBuffer loadModelFile(String modelPath) { InputStream is = null; diff --git a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/objectdetection/ui/ObjectCameraActivity.java b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/objectdetection/ui/ObjectCameraActivity.java index 1fe93f10689..a8804a66d83 100644 --- a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/objectdetection/ui/ObjectCameraActivity.java +++ b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/objectdetection/ui/ObjectCameraActivity.java @@ -19,9 +19,9 @@ import static com.mindspore.himindspore.objectdetection.bean.RecognitionObjectBe /** - * [入口主页面] + * main page of entrance * - * 向JNI传入图片,测试MindSpore模型加载推理等. + * Pass in pictures to JNI, test mindspore model, load reasoning, etc */ public class ObjectCameraActivity extends AppCompatActivity implements CameraPreview.RecognitionDataCallBack { 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 index 4589340260e..a0807e54a7f 100644 --- 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 @@ -46,7 +46,7 @@ public class ObjectDetectionMainActivity extends AppCompatActivity implements Vi } /** - * 权限申请结果回调 + * Authority application result callback */ @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { diff --git a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/objectdetection/ui/ObjectPhotoActivity.java b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/objectdetection/ui/ObjectPhotoActivity.java index a03013596b1..595e1f3e41d 100644 --- a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/objectdetection/ui/ObjectPhotoActivity.java +++ b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/objectdetection/ui/ObjectPhotoActivity.java @@ -113,7 +113,7 @@ public class ObjectPhotoActivity extends AppCompatActivity { String result = trackingMobile.MindSpore_runnet(bitmap); long endTime = System.currentTimeMillis(); - Log.d(TAG, "RUNNET 耗时:"+(endTime-startTime)+"ms"); + Log.d(TAG, "RUNNET CONSUMING:"+(endTime-startTime)+"ms"); Log.d(TAG, "result:"+ result); recognitionObjectBeanList = getRecognitionList(result); @@ -127,7 +127,7 @@ public class ObjectPhotoActivity extends AppCompatActivity { Canvas canvas = new Canvas(bitmap); Paint mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint.setTextSize(DisplayUtil.sp2px(this,16)); - //只绘制图形轮廓(描边) + //Draw only outline (stroke) mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeWidth(DisplayUtil.dip2px(this,2)); diff --git a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/objectdetection/ui/ObjectRectView.java b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/objectdetection/ui/ObjectRectView.java index b0d3a3e99d1..1bf6d98a987 100644 --- a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/objectdetection/ui/ObjectRectView.java +++ b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/objectdetection/ui/ObjectRectView.java @@ -19,11 +19,10 @@ import java.util.ArrayList; import java.util.List; /** - * 针对物体检测的矩形框绘制类 - *

- * 使用的API: - * 1. Canvas:代表“依附”于指定View的画布,用它的方法来绘制各种图形. - * 2. Paint:代表Canvas上的画笔,用于设置画笔颜色、画笔粗细、填充风格等. + * Rectangle drawing class for object detection + * + * 1. Canvas:Represents the canvas attached to the specified view and uses its method to draw various graphics + * 2. Paint:Represents the brush on canvas and is used to set brush color, brush thickness, fill style, etc */ public class ObjectRectView extends View { @@ -33,7 +32,7 @@ public class ObjectRectView extends View { private List mRecognitions = new ArrayList<>(); private Paint mPaint = null; - // 画框区域. + // Frame area private RectF mObjRectF; private Context context; @@ -61,13 +60,13 @@ public class ObjectRectView extends View { mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint.setTextSize(DisplayUtil.sp2px(context,16)); - //只绘制图形轮廓(描边) + //Draw only outline (stroke) mPaint.setStyle(Style.STROKE); mPaint.setStrokeWidth(DisplayUtil.dip2px(context,2)); } /** - * 传入需绘制信息 + * Input information to be drawn * * @param recognitions */ @@ -76,14 +75,11 @@ public class ObjectRectView extends View { mRecognitions.clear(); mRecognitions.addAll(recognitions); - - //重新draw(). invalidate(); } public void clearCanvas(){ mRecognitions.clear(); - //重新draw(). invalidate(); } diff --git a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/utils/DisplayUtil.java b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/utils/DisplayUtil.java index 65366868c45..caadaedd677 100644 --- a/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/utils/DisplayUtil.java +++ b/model_zoo/official/lite/Himindspore/app/src/main/java/com/mindspore/himindspore/utils/DisplayUtil.java @@ -9,37 +9,23 @@ public class DisplayUtil { throw new UnsupportedOperationException("cannot be instantiated"); } - /** - * 将px值转换为dip或dp值,保证尺寸大小不变 - * DisplayMetrics类中属性density - */ + public static int px2dip(Context context, float pxValue) { final float scale = context.getResources().getDisplayMetrics().density; return (int) (pxValue / scale + 0.5f); } - /** - * 将dip或dp值转换为px值,保证尺寸大小不变 - * DisplayMetrics类中属性density - */ + public static int dip2px(Context context, float dipValue) { final float scale = context.getResources().getDisplayMetrics().density; return (int) (dipValue * scale + 0.5f); } - /** - * 将px值转换为sp值,保证文字大小不变 - * DisplayMetrics类中属性scaledDensity - */ public static int px2sp(Context context, float pxValue) { final float fontScale = context.getResources().getDisplayMetrics().scaledDensity; return (int) (pxValue / fontScale + 0.5f); } - /** - * 将sp值转换为px值,保证文字大小不变 - * DisplayMetrics类中属性scaledDensity - */ public static int sp2px(Context context, float spValue) { final float fontScale = context.getResources().getDisplayMetrics().scaledDensity; return (int) (spValue * fontScale + 0.5f); diff --git a/model_zoo/official/lite/image_classification/app/src/main/cpp/MindSporeNetnative.cpp b/model_zoo/official/lite/image_classification/app/src/main/cpp/MindSporeNetnative.cpp index 34204b0e76c..9cf95356141 100644 --- a/model_zoo/official/lite/image_classification/app/src/main/cpp/MindSporeNetnative.cpp +++ b/model_zoo/official/lite/image_classification/app/src/main/cpp/MindSporeNetnative.cpp @@ -38,88 +38,88 @@ using mindspore::dataset::LDataType; static const int RET_CATEGORY_SUM = 410; static const char *labels_name_map[RET_CATEGORY_SUM] = { - {"Herd"}, {"Safari"}, {"Bangle"}, {"Cushion"}, {"Countertop"}, - {"Prom"}, {"Branch"}, {"Sports"}, {"Sky"}, {"Community"}, - {"Wheel"}, {"Cola"}, {"Tuxedo"}, {"Flowerpot"}, {"Team"}, - {"Computer"}, {"Unicycle"}, {"Brig"}, {"Aerospace engineering"}, {"Scuba diving"}, - {"Goggles"}, {"Fruit"}, {"Badminton"}, {"Horse"}, {"Sunglasses"}, - {"Fun"}, {"Prairie"}, {"Poster"}, {"Flag"}, {"Speedboat"}, - {"Eyelash"}, {"Veil"}, {"Mobile phone"}, {"Wheelbarrow"}, {"Saucer"}, - {"Leather"}, {"Drawer"}, {"Paper"}, {"Pier"}, {"Waterfowl"}, - {"Tights"}, {"Rickshaw"}, {"Vegetable"}, {"Handrail"}, {"Ice"}, - {"Metal"}, {"Flower"}, {"Wing"}, {"Silverware"}, {"Event"}, - {"Skyline"}, {"Money"}, {"Comics"}, {"Handbag"}, {"Porcelain"}, - {"Rodeo"}, {"Curtain"}, {"Tile"}, {"Human mouth"}, {"Army"}, - {"Menu"}, {"Boat"}, {"Snowboarding"}, {"Cairn terrier"}, {"Net"}, - {"Pasteles"}, {"Cup"}, {"Rugby"}, {"Pho"}, {"Cap"}, - {"Human hair"}, {"Surfing"}, {"Loveseat"}, {"Museum"}, {"Shipwreck"}, - {"Trunk (Tree)"}, {"Plush"}, {"Monochrome"}, {"Volcano"}, {"Rock"}, - {"Pillow"}, {"Presentation"}, {"Nebula"}, {"Subwoofer"}, {"Lake"}, - {"Sledding"}, {"Bangs"}, {"Tablecloth"}, {"Necklace"}, {"Swimwear"}, - {"Standing"}, {"Jeans"}, {"Carnival"}, {"Softball"}, {"Centrepiece"}, - {"Skateboarder"}, {"Cake"}, {"Dragon"}, {"Aurora"}, {"Skiing"}, - {"Bathroom"}, {"Dog"}, {"Needlework"}, {"Umbrella"}, {"Church"}, - {"Fire"}, {"Piano"}, {"Denim"}, {"Bridle"}, {"Cabinetry"}, - {"Lipstick"}, {"Ring"}, {"Television"}, {"Roller"}, {"Seal"}, - {"Concert"}, {"Product"}, {"News"}, {"Fast food"}, {"Horn (Animal)"}, - {"Tattoo"}, {"Bird"}, {"Bridegroom"}, {"Love"}, {"Helmet"}, - {"Dinosaur"}, {"Icing"}, {"Miniature"}, {"Tire"}, {"Toy"}, - {"Icicle"}, {"Jacket"}, {"Coffee"}, {"Mosque"}, {"Rowing"}, - {"Wetsuit"}, {"Camping"}, {"Underwater"}, {"Christmas"}, {"Gelato"}, - {"Whiteboard"}, {"Field"}, {"Ragdoll"}, {"Construction"}, {"Lampshade"}, - {"Palace"}, {"Meal"}, {"Factory"}, {"Cage"}, {"Clipper (Boat)"}, - {"Gymnastics"}, {"Turtle"}, {"Human foot"}, {"Marriage"}, {"Web page"}, - {"Human beard"}, {"Fog"}, {"Wool"}, {"Cappuccino"}, {"Lighthouse"}, - {"Lego"}, {"Sparkler"}, {"Sari"}, {"Model"}, {"Temple"}, - {"Beanie"}, {"Building"}, {"Waterfall"}, {"Penguin"}, {"Cave"}, - {"Stadium"}, {"Smile"}, {"Human hand"}, {"Park"}, {"Desk"}, - {"Shetland sheepdog"}, {"Bar"}, {"Eating"}, {"Neon"}, {"Dalmatian"}, - {"Crocodile"}, {"Wakeboarding"}, {"Longboard"}, {"Road"}, {"Race"}, - {"Kitchen"}, {"Odometer"}, {"Cliff"}, {"Fiction"}, {"School"}, - {"Interaction"}, {"Bullfighting"}, {"Boxer"}, {"Gown"}, {"Aquarium"}, - {"Superhero"}, {"Pie"}, {"Asphalt"}, {"Surfboard"}, {"Cheeseburger"}, - {"Screenshot"}, {"Supper"}, {"Laugh"}, {"Lunch"}, {"Party "}, - {"Glacier"}, {"Bench"}, {"Grandparent"}, {"Sink"}, {"Pomacentridae"}, - {"Blazer"}, {"Brick"}, {"Space"}, {"Backpacking"}, {"Stuffed toy"}, - {"Sushi"}, {"Glitter"}, {"Bonfire"}, {"Castle"}, {"Marathon"}, - {"Pizza"}, {"Beach"}, {"Human ear"}, {"Racing"}, {"Sitting"}, - {"Iceberg"}, {"Shelf"}, {"Vehicle"}, {"Pop music"}, {"Playground"}, - {"Clown"}, {"Car"}, {"Rein"}, {"Fur"}, {"Musician"}, - {"Casino"}, {"Baby"}, {"Alcohol"}, {"Strap"}, {"Reef"}, - {"Balloon"}, {"Outerwear"}, {"Cathedral"}, {"Competition"}, {"Joker"}, - {"Blackboard"}, {"Bunk bed"}, {"Bear"}, {"Moon"}, {"Archery"}, - {"Polo"}, {"River"}, {"Fishing"}, {"Ferris wheel"}, {"Mortarboard"}, - {"Bracelet"}, {"Flesh"}, {"Statue"}, {"Farm"}, {"Desert"}, - {"Chain"}, {"Aircraft"}, {"Textile"}, {"Hot dog"}, {"Knitting"}, - {"Singer"}, {"Juice"}, {"Circus"}, {"Chair"}, {"Musical instrument"}, - {"Room"}, {"Crochet"}, {"Sailboat"}, {"Newspaper"}, {"Santa claus"}, - {"Swamp"}, {"Skyscraper"}, {"Skin"}, {"Rocket"}, {"Aviation"}, - {"Airliner"}, {"Garden"}, {"Ruins"}, {"Storm"}, {"Glasses"}, - {"Balance"}, {"Nail (Body part)"}, {"Rainbow"}, {"Soil "}, {"Vacation "}, - {"Moustache"}, {"Doily"}, {"Food"}, {"Bride "}, {"Cattle"}, - {"Pocket"}, {"Infrastructure"}, {"Train"}, {"Gerbil"}, {"Fireworks"}, - {"Pet"}, {"Dam"}, {"Crew"}, {"Couch"}, {"Bathing"}, - {"Quilting"}, {"Motorcycle"}, {"Butterfly"}, {"Sled"}, {"Watercolor paint"}, - {"Rafting"}, {"Monument"}, {"Lightning"}, {"Sunset"}, {"Bumper"}, - {"Shoe"}, {"Waterskiing"}, {"Sneakers"}, {"Tower"}, {"Insect"}, - {"Pool"}, {"Placemat"}, {"Airplane"}, {"Plant"}, {"Jungle"}, - {"Armrest"}, {"Duck"}, {"Dress"}, {"Tableware"}, {"Petal"}, - {"Bus"}, {"Hanukkah"}, {"Forest"}, {"Hat"}, {"Barn"}, - {"Tubing"}, {"Snorkeling"}, {"Cool"}, {"Cookware and bakeware"}, {"Cycling"}, - {"Swing (Seat)"}, {"Muscle"}, {"Cat"}, {"Skateboard"}, {"Star"}, - {"Toe"}, {"Junk"}, {"Bicycle"}, {"Bedroom"}, {"Person"}, - {"Sand"}, {"Canyon"}, {"Tie"}, {"Twig"}, {"Sphynx"}, - {"Supervillain"}, {"Nightclub"}, {"Ranch"}, {"Pattern"}, {"Shorts"}, - {"Himalayan"}, {"Wall"}, {"Leggings"}, {"Windsurfing"}, {"Deejay"}, - {"Dance"}, {"Van"}, {"Bento"}, {"Sleep"}, {"Wine"}, - {"Picnic"}, {"Leisure"}, {"Dune"}, {"Crowd"}, {"Kayak"}, - {"Ballroom"}, {"Selfie"}, {"Graduation"}, {"Frigate"}, {"Mountain"}, - {"Dude"}, {"Windshield"}, {"Skiff"}, {"Class"}, {"Scarf"}, - {"Bull"}, {"Soccer"}, {"Bag"}, {"Basset hound"}, {"Tractor"}, - {"Swimming"}, {"Running"}, {"Track"}, {"Helicopter"}, {"Pitch"}, - {"Clock"}, {"Song"}, {"Jersey"}, {"Stairs"}, {"Flap"}, - {"Jewellery"}, {"Bridge"}, {"Cuisine"}, {"Bread"}, {"Caving"}, - {"Shell"}, {"Wreath"}, {"Roof"}, {"Cookie"}, {"Canoe"}}; + "Herd", "Safari", "Bangle", "Cushion", "Countertop", + "Prom", "Branch", "Sports", "Sky", "Community", + "Wheel", "Cola", "Tuxedo", "Flowerpot", "Team", + "Computer", "Unicycle", "Brig", "Aerospace engineering", "Scuba diving", + "Goggles", "Fruit", "Badminton", "Horse", "Sunglasses", + "Fun", "Prairie", "Poster", "Flag", "Speedboat", + "Eyelash", "Veil", "Mobile phone", "Wheelbarrow", "Saucer", + "Leather", "Drawer", "Paper", "Pier", "Waterfowl", + "Tights", "Rickshaw", "Vegetable", "Handrail", "Ice", + "Metal", "Flower", "Wing", "Silverware", "Event", + "Skyline", "Money", "Comics", "Handbag", "Porcelain", + "Rodeo", "Curtain", "Tile", "Human mouth", "Army", + "Menu", "Boat", "Snowboarding", "Cairn terrier", "Net", + "Pasteles", "Cup", "Rugby", "Pho", "Cap", + "Human hair", "Surfing", "Loveseat", "Museum", "Shipwreck", + "Trunk (Tree)", "Plush", "Monochrome", "Volcano", "Rock", + "Pillow", "Presentation", "Nebula", "Subwoofer", "Lake", + "Sledding", "Bangs", "Tablecloth", "Necklace", "Swimwear", + "Standing", "Jeans", "Carnival", "Softball", "Centrepiece", + "Skateboarder", "Cake", "Dragon", "Aurora", "Skiing", + "Bathroom", "Dog", "Needlework", "Umbrella", "Church", + "Fire", "Piano", "Denim", "Bridle", "Cabinetry", + "Lipstick", "Ring", "Television", "Roller", "Seal", + "Concert", "Product", "News", "Fast food", "Horn (Animal)", + "Tattoo", "Bird", "Bridegroom", "Love", "Helmet", + "Dinosaur", "Icing", "Miniature", "Tire", "Toy", + "Icicle", "Jacket", "Coffee", "Mosque", "Rowing", + "Wetsuit", "Camping", "Underwater", "Christmas", "Gelato", + "Whiteboard", "Field", "Ragdoll", "Construction", "Lampshade", + "Palace", "Meal", "Factory", "Cage", "Clipper (Boat)", + "Gymnastics", "Turtle", "Human foot", "Marriage", "Web page", + "Human beard", "Fog", "Wool", "Cappuccino", "Lighthouse", + "Lego", "Sparkler", "Sari", "Model", "Temple", + "Beanie", "Building", "Waterfall", "Penguin", "Cave", + "Stadium", "Smile", "Human hand", "Park", "Desk", + "Shetland sheepdog", "Bar", "Eating", "Neon", "Dalmatian", + "Crocodile", "Wakeboarding", "Longboard", "Road", "Race", + "Kitchen", "Odometer", "Cliff", "Fiction", "School", + "Interaction", "Bullfighting", "Boxer", "Gown", "Aquarium", + "Superhero", "Pie", "Asphalt", "Surfboard", "Cheeseburger", + "Screenshot", "Supper", "Laugh", "Lunch", "Party ", + "Glacier", "Bench", "Grandparent", "Sink", "Pomacentridae", + "Blazer", "Brick", "Space", "Backpacking", "Stuffed toy", + "Sushi", "Glitter", "Bonfire", "Castle", "Marathon", + "Pizza", "Beach", "Human ear", "Racing", "Sitting", + "Iceberg", "Shelf", "Vehicle", "Pop music", "Playground", + "Clown", "Car", "Rein", "Fur", "Musician", + "Casino", "Baby", "Alcohol", "Strap", "Reef", + "Balloon", "Outerwear", "Cathedral", "Competition", "Joker", + "Blackboard", "Bunk bed", "Bear", "Moon", "Archery", + "Polo", "River", "Fishing", "Ferris wheel", "Mortarboard", + "Bracelet", "Flesh", "Statue", "Farm", "Desert", + "Chain", "Aircraft", "Textile", "Hot dog", "Knitting", + "Singer", "Juice", "Circus", "Chair", "Musical instrument", + "Room", "Crochet", "Sailboat", "Newspaper", "Santa claus", + "Swamp", "Skyscraper", "Skin", "Rocket", "Aviation", + "Airliner", "Garden", "Ruins", "Storm", "Glasses", + "Balance", "Nail (Body part)", "Rainbow", "Soil ", "Vacation ", + "Moustache", "Doily", "Food", "Bride ", "Cattle", + "Pocket", "Infrastructure", "Train", "Gerbil", "Fireworks", + "Pet", "Dam", "Crew", "Couch", "Bathing", + "Quilting", "Motorcycle", "Butterfly", "Sled", "Watercolor paint", + "Rafting", "Monument", "Lightning", "Sunset", "Bumper", + "Shoe", "Waterskiing", "Sneakers", "Tower", "Insect", + "Pool", "Placemat", "Airplane", "Plant", "Jungle", + "Armrest", "Duck", "Dress", "Tableware", "Petal", + "Bus", "Hanukkah", "Forest", "Hat", "Barn", + "Tubing", "Snorkeling", "Cool", "Cookware and bakeware", "Cycling", + "Swing (Seat)", "Muscle", "Cat", "Skateboard", "Star", + "Toe", "Junk", "Bicycle", "Bedroom", "Person", + "Sand", "Canyon", "Tie", "Twig", "Sphynx", + "Supervillain", "Nightclub", "Ranch", "Pattern", "Shorts", + "Himalayan", "Wall", "Leggings", "Windsurfing", "Deejay", + "Dance", "Van", "Bento", "Sleep", "Wine", + "Picnic", "Leisure", "Dune", "Crowd", "Kayak", + "Ballroom", "Selfie", "Graduation", "Frigate", "Mountain", + "Dude", "Windshield", "Skiff", "Class", "Scarf", + "Bull", "Soccer", "Bag", "Basset hound", "Tractor", + "Swimming", "Running", "Track", "Helicopter", "Pitch", + "Clock", "Song", "Jersey", "Stairs", "Flap", + "Jewellery", "Bridge", "Cuisine", "Bread", "Caving", + "Shell", "Wreath", "Roof", "Cookie", "Canoe"}; static float g_thres_map[RET_CATEGORY_SUM] = { 0.23, 0.03, 0.10, 0.13, 0.03, diff --git a/model_zoo/official/lite/image_classification/app/src/main/java/com/mindspore/himindsporedemo/widget/AutoFitTextureView.java b/model_zoo/official/lite/image_classification/app/src/main/java/com/mindspore/himindsporedemo/widget/AutoFitTextureView.java index 9ca7f6ce135..cf9fb596307 100644 --- a/model_zoo/official/lite/image_classification/app/src/main/java/com/mindspore/himindsporedemo/widget/AutoFitTextureView.java +++ b/model_zoo/official/lite/image_classification/app/src/main/java/com/mindspore/himindsporedemo/widget/AutoFitTextureView.java @@ -60,7 +60,6 @@ public class AutoFitTextureView extends TextureView { super.onMeasure(widthMeasureSpec, heightMeasureSpec); int width = MeasureSpec.getSize(widthMeasureSpec); int height = MeasureSpec.getSize(heightMeasureSpec); - Log.e("AAA","onMeasure height>>"+height); if (0 == mRatioWidth || 0 == mRatioHeight) { setMeasuredDimension(width, height); diff --git a/model_zoo/official/lite/image_classification/app/src/main/java/com/mindspore/himindsporedemo/widget/CameraFragment.java b/model_zoo/official/lite/image_classification/app/src/main/java/com/mindspore/himindsporedemo/widget/CameraFragment.java index 6548b671422..0e3af9877c3 100644 --- a/model_zoo/official/lite/image_classification/app/src/main/java/com/mindspore/himindsporedemo/widget/CameraFragment.java +++ b/model_zoo/official/lite/image_classification/app/src/main/java/com/mindspore/himindsporedemo/widget/CameraFragment.java @@ -362,7 +362,6 @@ public class CameraFragment extends Fragment { @SuppressLint("MissingPermission") private void openCamera(int width, int height) { - Log.e("AAA","height>>"+height); setPreviewSize(width, height, streamConfigurationMap, largest); configureTransform(width, height); diff --git a/model_zoo/official/lite/object_detection/app/src/main/java/com/mindspore/hiobject/SplashActivity.java b/model_zoo/official/lite/object_detection/app/src/main/java/com/mindspore/hiobject/SplashActivity.java index e5422373982..6c69aa6b127 100644 --- a/model_zoo/official/lite/object_detection/app/src/main/java/com/mindspore/hiobject/SplashActivity.java +++ b/model_zoo/official/lite/object_detection/app/src/main/java/com/mindspore/hiobject/SplashActivity.java @@ -13,7 +13,6 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.core.app.ActivityCompat; import com.mindspore.hiobject.objectdetect.CameraActivity; -import com.mindspore.hiobject.objectdetect.DealDataActivity; import com.mindspore.hiobject.objectdetect.PhotoActivity; public class SplashActivity extends AppCompatActivity implements View.OnClickListener { @@ -21,7 +20,7 @@ public class SplashActivity extends AppCompatActivity implements View.OnClickLis private static final int RC_CHOOSE_PHOTO = 1; private static final int REQUEST_CAMERA_PERMISSION = 2; - private Button btnPhoto, btnCamera, btnDealData; + private Button btnPhoto, btnCamera; @Override protected void onCreate(Bundle savedInstanceState) { @@ -30,12 +29,9 @@ public class SplashActivity extends AppCompatActivity implements View.OnClickLis btnPhoto = findViewById(R.id.btn_photo); btnCamera = findViewById(R.id.btn_camera); - btnDealData = findViewById(R.id.btn_deal); - btnDealData.setVisibility(View.GONE); btnPhoto.setOnClickListener(this); btnCamera.setOnClickListener(this); - btnDealData.setOnClickListener(this); } @@ -50,15 +46,11 @@ public class SplashActivity extends AppCompatActivity implements View.OnClickLis 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); - - } else if (R.id.btn_deal == view.getId()) { - Intent intent = new Intent(SplashActivity.this, DealDataActivity.class); - startActivity(intent); } } /** - * 权限申请结果回调 + * Authority application result callback */ @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { diff --git a/model_zoo/official/lite/object_detection/app/src/main/java/com/mindspore/hiobject/help/ImageDegreeHelper.java b/model_zoo/official/lite/object_detection/app/src/main/java/com/mindspore/hiobject/help/ImageDegreeHelper.java index a1df52f05a8..d9ec0d17d10 100644 --- a/model_zoo/official/lite/object_detection/app/src/main/java/com/mindspore/hiobject/help/ImageDegreeHelper.java +++ b/model_zoo/official/lite/object_detection/app/src/main/java/com/mindspore/hiobject/help/ImageDegreeHelper.java @@ -16,9 +16,6 @@ import android.provider.MediaStore; import java.io.IOException; public class ImageDegreeHelper { - /** - * 专为Android4.4及以上设计的从Uri获取文件绝对路径,以前的方法已不好使 - */ @SuppressLint("NewApi") public static String getPath(final Context context, final Uri uri) { @@ -136,10 +133,10 @@ public class ImageDegreeHelper { } /** - * 读取照片旋转角度 + * Read photo rotation angle * - * @param path 照片路径 - * @return 角度 + * @param path Photo path + * @return angle */ public static int readPictureDegree(String path) { int degree = 0; @@ -166,11 +163,11 @@ public class ImageDegreeHelper { public static Bitmap rotaingImageView(int angle, Bitmap bitmap) { Bitmap returnBm = null; - // 根据旋转角度,生成旋转矩阵 + // According to the rotation angle, the rotation matrix is generated Matrix matrix = new Matrix(); matrix.postRotate(angle); try { - // 将原始图片按照旋转矩阵进行旋转,并得到新的图片 + // The original image is rotated according to the rotation matrix, and a new image is obtained returnBm = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); } catch (OutOfMemoryError e) { } diff --git a/model_zoo/official/lite/object_detection/app/src/main/java/com/mindspore/hiobject/help/TrackingMobile.java b/model_zoo/official/lite/object_detection/app/src/main/java/com/mindspore/hiobject/help/TrackingMobile.java index 35b38a0914f..dc5fe27bae5 100644 --- a/model_zoo/official/lite/object_detection/app/src/main/java/com/mindspore/hiobject/help/TrackingMobile.java +++ b/model_zoo/official/lite/object_detection/app/src/main/java/com/mindspore/hiobject/help/TrackingMobile.java @@ -35,52 +35,50 @@ public class TrackingMobile { } /** - * jni加载模型 + * JNI loading model * * @param assetManager assetManager * @param buffer buffer * @param numThread numThread - * @return 加载模型数据 + * @return Load model data */ public native long loadModel(AssetManager assetManager, ByteBuffer buffer, int numThread); /** - * jni运行模型 + * JNI run model * - * @param netEnv 加载模型数据 - * @param img 当前图片 - * @return 运行模型数据 + * @param netEnv Load model data + * @param img Current picture + * @return Run model data */ public native String runNet(long netEnv, Bitmap img); /** - * 解绑模型数据 + * Unbind model data * - * @param netEnv 模型数据 - * @return 解绑状态 + * @param netEnv model data + * @return Unbound state */ public native boolean unloadModel(long netEnv); /** - * C++侧封装成了MSNetWorks类的方法 + * C++ Methods encapsulated into the msnetworks class * - * @param assetManager 模型文件位置 - * @return 加载模型文件状态 + * @param assetManager Model file location + * @return Loading model file status */ public boolean loadModelFromBuf(AssetManager assetManager) { -// String ModelPath = "model/model_hebing_3branch.ms"; String ModelPath = "model/ssd.ms"; - ByteBuffer buffer = loadModelFile(ModelPath); netEnv = loadModel(assetManager, buffer, 2); return true; } /** - * 运行Mindspore + * Run Mindspore * - * @param img 当前图片识别 - * @return 识别出来的文字信息 + * @param img Current image recognition + * @return Recognized text information */ public String MindSpore_runnet(Bitmap img) { String ret_str = runNet(netEnv, img); @@ -88,7 +86,7 @@ public class TrackingMobile { } /** - * 解绑模型 + * Unbound model * @return true */ public boolean unloadModel() { @@ -97,9 +95,9 @@ public class TrackingMobile { } /** - * 加载模型文件流 - * @param modelPath 模型文件路径 - * @return 加载模型文件流 + * Load model file stream + * @param modelPath Model file path + * @return Load model file stream */ public ByteBuffer loadModelFile(String modelPath) { InputStream is = null; diff --git a/model_zoo/official/lite/object_detection/app/src/main/java/com/mindspore/hiobject/objectdetect/CameraActivity.java b/model_zoo/official/lite/object_detection/app/src/main/java/com/mindspore/hiobject/objectdetect/CameraActivity.java index 68c75794df9..3e8d1b39616 100644 --- a/model_zoo/official/lite/object_detection/app/src/main/java/com/mindspore/hiobject/objectdetect/CameraActivity.java +++ b/model_zoo/official/lite/object_detection/app/src/main/java/com/mindspore/hiobject/objectdetect/CameraActivity.java @@ -8,9 +8,9 @@ import androidx.appcompat.app.AppCompatActivity; import com.mindspore.hiobject.R; /** - * [入口主页面] + * Main page of entrance * - * 向JNI传入图片,测试MindSpore模型加载推理等. + * Pass in pictures to JNI, test mindspore model, load reasoning, etc */ public class CameraActivity extends AppCompatActivity { @@ -25,7 +25,6 @@ public class CameraActivity extends AppCompatActivity { setContentView(R.layout.activity_camera); if (savedInstanceState != null && this.clearFragmentsTag()) { - // 重建时清除 fragment的状态 savedInstanceState.remove(BUNDLE_FRAGMENTS_KEY); } @@ -37,7 +36,6 @@ public class CameraActivity extends AppCompatActivity { protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if (outState != null && this.clearFragmentsTag()) { - // 销毁时不保存fragment的状态 outState.remove(BUNDLE_FRAGMENTS_KEY); } } diff --git a/model_zoo/official/lite/object_detection/app/src/main/java/com/mindspore/hiobject/objectdetect/DealDataActivity.java b/model_zoo/official/lite/object_detection/app/src/main/java/com/mindspore/hiobject/objectdetect/DealDataActivity.java deleted file mode 100644 index 5b057c381b5..00000000000 --- a/model_zoo/official/lite/object_detection/app/src/main/java/com/mindspore/hiobject/objectdetect/DealDataActivity.java +++ /dev/null @@ -1,260 +0,0 @@ -package com.mindspore.hiobject.objectdetect; - -import android.Manifest; -import android.content.pm.PackageManager; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.os.Build; -import android.os.Bundle; -import android.os.Environment; -import android.os.Handler; -import android.os.Message; -import android.util.Log; -import android.widget.Toast; - -import androidx.annotation.NonNull; -import androidx.appcompat.app.AppCompatActivity; - -import com.mindspore.hiobject.R; -import com.mindspore.hiobject.help.TrackingMobile; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.ObjectOutputStream; -import java.util.ArrayList; -import java.util.List; - -/** - * [入口主页面] - *

- * 向JNI传入图片,测试MindSpore模型加载推理等. - */ - -public class DealDataActivity extends AppCompatActivity { - private final String TAG = "DealDataActivity"; - - //自行将v2017的图片放入手机sdcard的位置 - private final static String IMGPATH = "/sdcard/val2017"; - private final static String IMG_RESULT_PATH = "/sdcard/val2017result/result.txt"; - private final static String IMG_RESULT_SINGLE_PATH = "/sdcard/val2017result/result2.txt"; - - private Bitmap mBitmap; - private TrackingMobile mTrackingMobile; - - private static final String PERMISSION_READ_EXTERNAL_STORAGEA = Manifest.permission.READ_EXTERNAL_STORAGE; - private static final String PERMISSION_WRITE_EXTERNAL_STORAGEA = Manifest.permission.WRITE_EXTERNAL_STORAGE; - - private static final int PERMISSIONS_REQUEST = 1; - - - private Handler handler = new Handler() { - @Override - public void handleMessage(@NonNull Message msg) { - super.handleMessage(msg); - if (1 == msg.what) { - dealData(); - } - } - }; - - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_dealdata); - - - try { - mTrackingMobile = new TrackingMobile(this); - } catch (FileNotFoundException e) { - Log.e(TAG, Log.getStackTraceString(e)); - } - mTrackingMobile.loadModelFromBuf(getAssets()); - - if (hasPermission()) { - getImgFileList(); - } else { - requestPermission(); - } - - } - - - private List imgFileList; - - private void getImgFileList() { - new Thread(new Runnable() { - @Override - public void run() { - imgFileList = getFilesAllName(IMGPATH); - Message message = new Message(); - message.what = 1; - handler.sendMessage(message); - } - }).start(); - } - - - List dealList = new ArrayList<>(); - - private void dealData() { - if (imgFileList != null && imgFileList.size() > 0) { - Log.d(TAG, "imgFileList size()>>" + imgFileList.size()); - for (int i = 0; i < imgFileList.size(); i++) { - Bitmap bitmap = BitmapFactory.decodeFile(imgFileList.get(i)).copy(Bitmap.Config.ARGB_8888, true); - - String result = mTrackingMobile.MindSpore_runnet(bitmap); - String fileName = imgFileList.get(i).substring(imgFileList.get(i).lastIndexOf("/") + 1); - Log.d(TAG, "index>>>" + i + ">>" + fileName + ">>result" + result); - StringBuilder sb = new StringBuilder(); - sb.append(fileName).append("_").append(result); - dealList.add(sb.toString()); - } - Log.d(TAG, "dealList >>>" + dealList.size()); - writeListIntoSDcard(IMG_RESULT_PATH, dealList); - } - } - - private void dealSingleData() { - String fileFullName = IMGPATH + "/error.jpg"; - Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.error).copy(Bitmap.Config.ARGB_8888, true); - if (bitmap != null) { - - String result = mTrackingMobile.MindSpore_runnet(bitmap); - Log.d(TAG, ">>result" + result); - StringBuilder sb = new StringBuilder(); - sb.append("error.jpg").append("_").append(result); - } - } - - - public boolean writeListIntoSDcard(String fileName, List list) { - if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { - File sdFile = new File(fileName); - try { - FileOutputStream fos = new FileOutputStream(sdFile); - ObjectOutputStream oos = new ObjectOutputStream(fos); - oos.writeObject(list);//写入 - fos.close(); - oos.close(); - return true; - } catch (FileNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - return false; - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - return false; - } - } else { - return false; - } - } - - - public boolean writeStringIntoSDcard(String fileName, String content) { - if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { - File sdFile = new File(fileName); - try { - FileOutputStream fos = new FileOutputStream(sdFile); - ObjectOutputStream oos = new ObjectOutputStream(fos); - oos.writeObject(content);//写入 - fos.close(); - oos.close(); - return true; - } catch (FileNotFoundException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - return false; - } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - return false; - } - } else { - return false; - } - } - - @Override - public void onRequestPermissionsResult(final int requestCode, final String[] permissions, - final int[] grantResults) { - super.onRequestPermissionsResult(requestCode, permissions, grantResults); - if (requestCode == PERMISSIONS_REQUEST) { - if (allPermissionsGranted(grantResults)) { - getImgFileList(); - } else { - requestPermission(); - } - } - } - - private static boolean allPermissionsGranted(final int[] grantResults) { - for (int result : grantResults) { - if (result != PackageManager.PERMISSION_GRANTED) { - return false; - } - } - return true; - } - - private boolean hasPermission() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - return checkSelfPermission(PERMISSION_READ_EXTERNAL_STORAGEA) == PackageManager.PERMISSION_GRANTED && - checkSelfPermission(PERMISSION_WRITE_EXTERNAL_STORAGEA) == PackageManager.PERMISSION_GRANTED; - } else { - return true; - } - } - - private void requestPermission() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { - if (shouldShowRequestPermissionRationale(PERMISSION_READ_EXTERNAL_STORAGEA)) { - Toast.makeText(this, "Read permission is required for this demo", Toast.LENGTH_LONG) - .show(); - } - if (shouldShowRequestPermissionRationale(PERMISSION_WRITE_EXTERNAL_STORAGEA)) { - Toast.makeText(this, "WRITE permission is required for this demo", Toast.LENGTH_LONG) - .show(); - } - requestPermissions(new String[]{PERMISSION_READ_EXTERNAL_STORAGEA, PERMISSION_WRITE_EXTERNAL_STORAGEA}, PERMISSIONS_REQUEST); - } - } - - - public List getFilesAllName(String path) { - //传入指定文件夹的路径 - File file = new File(path); - if (null == file || !file.isDirectory()) { - return null; - } - File[] files = file.listFiles(); - List imagePaths = new ArrayList<>(); - for (int i = 0; i < files.length; i++) { - if (checkIsImageFile(files[i].getPath())) { - imagePaths.add(files[i].getPath()); - } - } - return imagePaths; - } - - /** - * 判断是否是照片 - */ - public boolean checkIsImageFile(String fName) { - boolean isImageFile = false; - //获取拓展名 - String fileEnd = fName.substring(fName.lastIndexOf(".") + 1, - fName.length()).toLowerCase(); - if (fileEnd.equals("jpg") || fileEnd.equals("png") || fileEnd.equals("gif") - || fileEnd.equals("jpeg") || fileEnd.equals("bmp")) { - isImageFile = true; - } else { - isImageFile = false; - } - return isImageFile; - } -} diff --git a/model_zoo/official/lite/object_detection/app/src/main/java/com/mindspore/hiobject/objectdetect/ObjectRectView.java b/model_zoo/official/lite/object_detection/app/src/main/java/com/mindspore/hiobject/objectdetect/ObjectRectView.java index ae30b68ea17..4b5306f07d4 100644 --- a/model_zoo/official/lite/object_detection/app/src/main/java/com/mindspore/hiobject/objectdetect/ObjectRectView.java +++ b/model_zoo/official/lite/object_detection/app/src/main/java/com/mindspore/hiobject/objectdetect/ObjectRectView.java @@ -16,11 +16,10 @@ import java.util.ArrayList; import java.util.List; /** - * 针对物体检测的矩形框绘制类 - *

- * 使用的API: - * 1. Canvas:代表“依附”于指定View的画布,用它的方法来绘制各种图形. - * 2. Paint:代表Canvas上的画笔,用于设置画笔颜色、画笔粗细、填充风格等. + * Rectangle drawing class for object detection + * + * 1. Canvas:Represents the canvas attached to the specified view and uses its method to draw various graphics + * 2. Paint:Represents the brush on canvas and is used to set brush color, brush thickness, fill style, etc */ public class ObjectRectView extends View { @@ -30,7 +29,7 @@ public class ObjectRectView extends View { private List mRecognitions = new ArrayList<>(); private Paint mPaint = null; - // 画框区域. + // Frame area private RectF mObjRectF; @@ -58,13 +57,13 @@ public class ObjectRectView extends View { mPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mPaint.setTextSize(50); - //只绘制图形轮廓(描边) + //Draw only outline (stroke) mPaint.setStyle(Style.STROKE); mPaint.setStrokeWidth(5); } /** - * 传入需绘制信息 + * Input information to be drawn * * @param recognitions */ @@ -74,13 +73,11 @@ public class ObjectRectView extends View { mRecognitions.clear(); mRecognitions.addAll(recognitions); - //重新draw(). invalidate(); } public void clearCanvas(){ mRecognitions.clear(); - //重新draw(). invalidate(); } diff --git a/model_zoo/official/lite/object_detection/app/src/main/java/com/mindspore/hiobject/objectdetect/PhotoActivity.java b/model_zoo/official/lite/object_detection/app/src/main/java/com/mindspore/hiobject/objectdetect/PhotoActivity.java index f28447c05de..829d1b54da0 100644 --- a/model_zoo/official/lite/object_detection/app/src/main/java/com/mindspore/hiobject/objectdetect/PhotoActivity.java +++ b/model_zoo/official/lite/object_detection/app/src/main/java/com/mindspore/hiobject/objectdetect/PhotoActivity.java @@ -71,7 +71,7 @@ public class PhotoActivity extends AppCompatActivity { String result = trackingMobile.MindSpore_runnet(bitmap); long endTime = System.currentTimeMillis(); - Log.d(TAG, "RUNNET 耗时:"+(endTime-startTime)+"ms"); + Log.d(TAG, "RUNNET CONSUMING:"+(endTime-startTime)+"ms"); Log.d(TAG, "result:"+ result); recognitionObjectBeanList = getRecognitionList(result);