diff --git a/Mindspore.AI/entry/src/main/cpp/CMakeLists.txt b/Mindspore.AI/entry/src/main/cpp/CMakeLists.txt index c2dcb556849dee44dfaf51cbe5e6dc53759ee999..b7426fb3b2bad3801554b2c62ba04b2de435e3d3 100644 --- a/Mindspore.AI/entry/src/main/cpp/CMakeLists.txt +++ b/Mindspore.AI/entry/src/main/cpp/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright 2024 Unionman Technology Co., Ltd. +# Copyright 2023 Unionman Technology Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -160,9 +160,8 @@ add_library( libtegra_hal STATIC IMPORTED ) set_target_properties(libtegra_hal PROPERTIES IMPORTED_LOCATION ${NATIVE_ROOT_PATH}/third_party/opencv/${OHOS_ARCH}/opencv4/3rdparty/libtegra_hal.a) - - target_link_libraries(mslite_napi PUBLIC libtegra_hal) + target_link_libraries(mslite_napi PUBLIC hilog_ndk.z) target_link_libraries(mslite_napi PUBLIC ace_ndk.z) target_link_libraries(mslite_napi PUBLIC ace_napi.z) diff --git a/Mindspore.AI/entry/src/main/cpp/include/mslite_data_type.h b/Mindspore.AI/entry/src/main/cpp/include/mslite_data_type.h index 73939b888e53d581ce90b9e07ae573bf93708812..fc8d955025b67b165d0fab21140396f60084872d 100644 --- a/Mindspore.AI/entry/src/main/cpp/include/mslite_data_type.h +++ b/Mindspore.AI/entry/src/main/cpp/include/mslite_data_type.h @@ -1,5 +1,5 @@ /* - * Copyright 2024 Unionman Technology Co., Ltd. + * Copyright 2023 Unionman Technology Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/Mindspore.AI/entry/src/main/cpp/include/mslite_errors.h b/Mindspore.AI/entry/src/main/cpp/include/mslite_errors.h index 4873f82bd2d462ecc33dc4eb0edcb6b323a4dca4..36e2529f99128a27a8841020a41b25c5c15477de 100644 --- a/Mindspore.AI/entry/src/main/cpp/include/mslite_errors.h +++ b/Mindspore.AI/entry/src/main/cpp/include/mslite_errors.h @@ -1,5 +1,5 @@ /* - * Copyright 2024 Unionman Technology Co., Ltd. + * Copyright 2023 Unionman Technology Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/Mindspore.AI/entry/src/main/cpp/include/mslite_log.h b/Mindspore.AI/entry/src/main/cpp/include/mslite_log.h index d741b9e7e8363a22103779acceaef1d14d55fb6f..449698c881d6155cff365ebdab3a507288dc37e6 100644 --- a/Mindspore.AI/entry/src/main/cpp/include/mslite_log.h +++ b/Mindspore.AI/entry/src/main/cpp/include/mslite_log.h @@ -1,5 +1,5 @@ /* - * Copyright 2024 Unionman Technology Co., Ltd. + * Copyright 2023 Unionman Technology Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/Mindspore.AI/entry/src/main/cpp/include/napi_error.h b/Mindspore.AI/entry/src/main/cpp/include/napi_error.h index 7228d0d051afef1c79b61d4568dde3157e2462d7..a52282dc04e00f4092a03aa61ab10887c5957606 100644 --- a/Mindspore.AI/entry/src/main/cpp/include/napi_error.h +++ b/Mindspore.AI/entry/src/main/cpp/include/napi_error.h @@ -1,5 +1,5 @@ /* - * Copyright 2024 Unionman Technology Co., Ltd. + * Copyright 2023 Unionman Technology Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/Mindspore.AI/entry/src/main/cpp/include/napi_utils.h b/Mindspore.AI/entry/src/main/cpp/include/napi_utils.h index 123ad117d1084f46f129833c221d7b8340f09f74..b57ec6a944e7ecae7f47b396fc0398892f1e6db8 100644 --- a/Mindspore.AI/entry/src/main/cpp/include/napi_utils.h +++ b/Mindspore.AI/entry/src/main/cpp/include/napi_utils.h @@ -1,5 +1,5 @@ /* - * Copyright 2024 Unionman Technology Co., Ltd. + * Copyright 2023 Unionman Technology Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/Mindspore.AI/entry/src/main/cpp/include/native_common.h b/Mindspore.AI/entry/src/main/cpp/include/native_common.h index 8818691834ee16efc15c1765280bcd1cfde364b9..5eaf0bfbc4b64511cb1921131038eb18cf74c635 100644 --- a/Mindspore.AI/entry/src/main/cpp/include/native_common.h +++ b/Mindspore.AI/entry/src/main/cpp/include/native_common.h @@ -1,5 +1,5 @@ /* - * Copyright 2024 Unionman Technology Co., Ltd. + * Copyright 2023 Unionman Technology Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/Mindspore.AI/entry/src/main/cpp/src/mslite_napi.cpp b/Mindspore.AI/entry/src/main/cpp/src/mslite_napi.cpp index e545b9bfa9a7ca84ef06b79de078ed07b4a227a2..b6e9ab081b0a597ae3c51fdfffcf4cd9c83546b6 100644 --- a/Mindspore.AI/entry/src/main/cpp/src/mslite_napi.cpp +++ b/Mindspore.AI/entry/src/main/cpp/src/mslite_napi.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2024 Unionman Technology Co., Ltd. + * Copyright 2023 Unionman Technology Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -31,6 +31,7 @@ #include #include #include "napi_utils.h" +#include #define MAX_MODEL_PATH_LENGTH 256 @@ -38,6 +39,9 @@ using namespace cv; using namespace OHOS::MSAI; OH_AI_ModelHandle modelms = nullptr; + +int async_creat = 0; + ///////////////////////// static cv::Mat src; @@ -367,12 +371,15 @@ static void FillTensorWithRandom(OH_AI_TensorHandle msTensor) { int index = 0; for (int i = 0; i < image.rows; i++) { uchar *ptr = image.ptr(i); + // char raw_res[28 * 5]; for (int j = 0; j < image.cols * image.channels(); j++) { *(data + index) = (float)ptr[j] / 255; +// *(data + j) = (float)ptr[j] / 255; index++; + } } - LOGI("index-%d-", index); +// LOGI("index-%d-", index); } // fill data to inputs tensor @@ -387,6 +394,13 @@ static int FillInputTensors(OH_AI_TensorHandleArray &inputs) { static void RunMSLiteModel(OH_AI_ModelHandle model, InferResult& inferResult) { LOGI("Run RunMSLiteModel...................\n"); + clock_t start; + double fps; + double cpu_time_used; + + start = clock(); + + float threshold = 0.25; float iou_threshold = 0.45; float biases[18] = {10, 13, 16, 30, 33, 23, 30, 61, 62, 45, 59, 119, 116, 90, 156, 198, 373, 326}; @@ -396,7 +410,13 @@ static void RunMSLiteModel(OH_AI_ModelHandle model, InferResult& inferResult) { // 设置模型输入数据 auto inputs = OH_AI_ModelGetInputs(model); FillInputTensors(inputs); - + + //end to record usage time + cpu_time_used = ((double) (clock() - start)) / CLOCKS_PER_SEC; + fps = 1/ cpu_time_used; + LOGI("==========================set input time: %f s; fps: %f\n", cpu_time_used, fps); + + start = clock(); auto outputs = OH_AI_ModelGetOutputs(model); // 执行推理并打印输出 @@ -407,8 +427,12 @@ static void RunMSLiteModel(OH_AI_ModelHandle model, InferResult& inferResult) { return; } LOGI("Run MSLite model success.\n"); - - + //end to record usage time + cpu_time_used = ((double) (clock() - start)) / CLOCKS_PER_SEC; + fps = 1/ cpu_time_used; + LOGI("========================== output time: %f s; fps: %f\n", cpu_time_used, fps); + + start = clock(); LOGI("Get model outputs:\n"); for (size_t i = 0; i < outputs.handle_num; i++) { auto tensor = outputs.handle_list[i]; @@ -419,9 +443,9 @@ static void RunMSLiteModel(OH_AI_ModelHandle model, InferResult& inferResult) { int max_num = (int)OH_AI_TensorGetElementNum(tensor); LOGI("**********max numbers is [%d]*********.\n", max_num); if (max_num == 80 * 80 * 85 * 3) { - LOGI("**********copy %d*********.\n", max_num); - flatten((float*)out_data, 80 * 80, 85 * 3, 1, 1); - yolo_v5_post_process_onescale((float*)out_data, &biases[0], threshold, 8, input); +// LOGI("**********copy %d*********.\n", max_num); +// flatten((float*)out_data, 80 * 80, 85 * 3, 1, 1); +// yolo_v5_post_process_onescale((float*)out_data, &biases[0], threshold, 8, input); } if (max_num == 40 * 40 * 85 * 3) { LOGI("**********copy %d*********.\n", max_num); @@ -433,13 +457,17 @@ static void RunMSLiteModel(OH_AI_ModelHandle model, InferResult& inferResult) { yolo_v5_post_process_onescale((float*)out_data, &biases[12], threshold, 32, input); } } - + //end to record usage time + cpu_time_used = ((double) (clock() - start)) / CLOCKS_PER_SEC; + fps = 1/ cpu_time_used; + LOGI("========================== output fun time: %f s; fps: %f\n", cpu_time_used, fps); + start = clock(); inferResult.id = 0; res = nms(input, iou_threshold); for (int i = 0; i < res.size(); i++) { LOGI("%s :%d %d %d %d %f\n", classes[res[i].classes].c_str(), res[i].x, res[i].y, res[i].w, res[i].h, res[i].score); - cv::rectangle(src, Point(res[i].x, res[i].y), Point(res[i].w, res[i].h), cv::Scalar(255, 0, 0), 2); +// cv::rectangle(src, Point(res[i].x, res[i].y), Point(res[i].w, res[i].h), cv::Scalar(255, 0, 0), 2); inferResult.objects[i].left = res[i].x; inferResult.objects[i].top = res[i].y; inferResult.objects[i].right = res[i].w; @@ -448,8 +476,13 @@ static void RunMSLiteModel(OH_AI_ModelHandle model, InferResult& inferResult) { inferResult.objects[i].prop = res[i].score; } inferResult.count = res.size(); - -// OH_AI_ModelDestroy(&model); + //end to record usage time + cpu_time_used = ((double) (clock() - start)) / CLOCKS_PER_SEC; + fps = 1/ cpu_time_used; + LOGI("========================== output nms time: %f s; fps: %f\n", cpu_time_used, fps); +// imwrite("/data/storage/el2/base/haps/entry/files/a.png", src); +// imwrite("/data/storage/el2/base/haps/entry/files/b.png", image); + // OH_AI_ModelDestroy(&model); } @@ -526,45 +559,61 @@ int32_t ParsePicDesc(napi_env env, napi_value args, PicDescNapi &picDescNapi) { /// static cv::Mat PreProcess(PicDesc &picDesc, std::string &picData, cv::Mat &frame) { + + clock_t start; + double fps; + double cpu_time_used; + start = clock(); if (picData.empty()) { LOGE("PreProcess: input pic data is empty."); return frame; } - - std::vector inBuffer(picData.begin(), picData.end()); - size_t size = inBuffer.size(); - LOGI("inBuffer = %{public}d", size); +#if 0 + size_t size = picData.size(); unsigned char *array = new unsigned char[size]; - for (size_t i = 0; i < size; ++i) { - array[i] = inBuffer[i]; - } + std::copy(picData.begin(), picData.end(), array); + + cpu_time_used = ((double)(clock() - start)) / CLOCKS_PER_SEC; + fps = 1 / cpu_time_used; + LOGI("====================preprocess std::copy array: %f s; fps: %f\n", cpu_time_used, fps); + start = clock(); +#endif cv::Mat yuv(picDesc.width * 3 / 2, picDesc.height, CV_8UC1); - yuv.data = array; + yuv.data = (unsigned char *)(picData.data()); // array; cv::cvtColor(yuv, frame, COLOR_YUV420sp2BGR); - + LOGI("yuv trans to bgr"); if (frame.data == nullptr || frame.channels() != 3 || frame.rows == 0 || frame.cols == 0) { LOGE("PreProcess failed."); return frame; } - + cpu_time_used = ((double)(clock() - start)) / CLOCKS_PER_SEC; + fps = 1 / cpu_time_used; + LOGI("====================preprocess yuv2bgr: %f s; fps: %f\n", cpu_time_used, fps); + // LOGI("transpose start"); +#if 0 + start = clock(); cv::Mat rotated; cv::transpose(frame, rotated); cv::flip(rotated, rotated, 1); +#endif + // LOGI("transpose over"); + // LOGI("Input: width = %{public}d, height = %{public}d", picDesc.width, picDesc.height); - LOGN("Input: width = %{public}d, height = %{public}d", picDesc.width, picDesc.height); - -// #define DEBUG_MODE 1 + // #define DEBUG_MODE 1 #ifdef DEBUG_MODE - count++; + char name[256]; - sprintf(name, "/data/storage/el2/base/haps/entry/files/IMG_%03d.jpg", count); + sprintf(name, "/data/storage/el2/base/haps/entry/files/IMG_%03d.jpg", 1); imwrite(name, rotated); #endif + // cpu_time_used = ((double) (clock() - start)) / CLOCKS_PER_SEC; + // fps = 1/ cpu_time_used; + // LOGI("====================preprocess transpose time: %f s; fps: %f\n", cpu_time_used, fps); + // delete[] array; - delete[] array; - - return rotated; + return frame; + // return rotated; } /// @@ -638,7 +687,7 @@ static void ExecuteCB(napi_env env, void *data) { context->modelId, (int)context->picDesc.width, (int)context->picDesc.height, (int)context->picDesc.dataSize); InferResult inferResult {}; - + image = PreProcess(context->picDesc, context->data, src); LOGI("run ms............"); RunMSLiteModel(modelms, inferResult); @@ -673,12 +722,13 @@ static void PromiseCompleteCB(napi_env env, napi_status status, void *data) { LOGD("PromiseCompleteCB success."); napi_resolve_deferred(env, context->deferred, result); } - + if (context->callbackRef != nullptr) { napi_delete_reference(env, context->callbackRef); } napi_delete_async_work(env, context->asyncWork); + delete context; } static void SetData(std::unique_ptr& asyncContext, int32_t modelId, @@ -704,7 +754,7 @@ static napi_value ObjectDectionInit(napi_env env, napi_callback_info info) napi_get_undefined(env, &result); GET_PARAMS(env, info, 1); - const std::string modelName = "yolov5s_pruned.ms"; + const std::string modelName = "yolov5s_pruned.ms"; //yolov5s_pruned.ms modified_best.ms yolov5s_c100_e100_cut_sim_quant_uni_trans.ms size_t modelSize; auto resourcesManager = OH_ResourceManager_InitNativeResourceManager(env, argv[0]); auto modelBuffer = ReadModelFile(resourcesManager, modelName, &modelSize); @@ -732,6 +782,10 @@ static napi_value ObjectDectionInit(napi_env env, napi_callback_info info) return success_ret; } +static void nothing(napi_env env, void *data) {} +static void nothing2(napi_env env, napi_status status, void *data) {} + + static napi_value ObjectDectionProcess(napi_env env, napi_callback_info info) { napi_value promise = nullptr; @@ -745,6 +799,7 @@ static napi_value ObjectDectionProcess(napi_env env, napi_callback_info info) napi_value undefinedResult = nullptr; napi_get_undefined(env, &undefinedResult); std::unique_ptr asyncContext = std::make_unique(); + if (asyncContext == nullptr) { LOGE("AsyncContext object create failed."); return undefinedResult; @@ -789,10 +844,16 @@ static napi_value ObjectDectionProcess(napi_env env, napi_callback_info info) LOGE("create callback failed."); return undefinedResult; } + if(1){ + status = napi_create_async_work(env, nullptr, resourceName, ExecuteCB, PromiseCompleteCB, + static_cast(asyncContext.get()), &asyncContext->asyncWork); + async_creat = 1; + } - status = napi_create_async_work(env, nullptr, resourceName, ExecuteCB, PromiseCompleteCB, - static_cast(asyncContext.get()), &asyncContext->asyncWork); - if (status != napi_ok) { + +// status = napi_create_async_work(env, nullptr, resourceName, nothing, nothing2, +// (void *)(asyncContext.get()), &asyncContext->asyncWork); + if (status != napi_ok) { LOGE("napi_create_async_work failed."); return undefinedResult; } @@ -800,7 +861,10 @@ static napi_value ObjectDectionProcess(napi_env env, napi_callback_info info) status = napi_queue_async_work(env, asyncContext->asyncWork); if (status == napi_ok) { asyncContext.release(); + LOGI("===================napi_queue_async_work ok."); +// asyncContext = nullptr; } else { + LOGI("===================napi_queue_async_work failed."); return undefinedResult; } @@ -808,45 +872,42 @@ static napi_value ObjectDectionProcess(napi_env env, napi_callback_info info) return promise; } -static napi_value ObjectDectionDeInit(napi_env env, napi_callback_info info) -{ + + +static napi_value ObjectDectionDeInit(napi_env env, napi_callback_info info) { LOGI("ObjectDectionDeinit"); napi_value success_ret; napi_create_int32(env, 0, &success_ret); return success_ret; -} + } -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) { - napi_property_descriptor desc[] = { - {"Init", nullptr, ObjectDectionInit, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"Process", nullptr, ObjectDectionProcess, nullptr, nullptr, nullptr, napi_default, nullptr}, - {"DeInit", nullptr, ObjectDectionDeInit, nullptr, nullptr, nullptr, napi_default, nullptr} + EXTERN_C_START + static napi_value Init(napi_env env, napi_value exports) { + napi_property_descriptor desc[] = { + {"Init", nullptr, ObjectDectionInit, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"Process", nullptr, ObjectDectionProcess, nullptr, nullptr, nullptr, napi_default, nullptr}, + {"DeInit", nullptr, ObjectDectionDeInit, nullptr, nullptr, nullptr, napi_default, nullptr}}; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; + } + EXTERN_C_END + + /* + * Napi Module define + */ + static napi_module msLiteModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "mslite_napi", + .nm_priv = ((void *)0), + .reserved = {0}, }; - napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); - return exports; -} -EXTERN_C_END - -/* - * Napi Module define - */ -static napi_module msLiteModule = { - .nm_version = 1, - .nm_flags = 0, - .nm_filename = nullptr, - .nm_register_func = Init, - .nm_modname = "mslite_napi", - .nm_priv = ((void*)0), - .reserved = { 0 }, -}; -/* - * Module register function - */ -extern "C" __attribute__((constructor)) void RegisterModule(void) -{ - napi_module_register(&msLiteModule); -} + /* + * Module register function + */ + extern "C" __attribute__((constructor)) void RegisterModule(void) { napi_module_register(&msLiteModule); } diff --git a/Mindspore.AI/entry/src/main/cpp/src/utils/napi_error.cpp b/Mindspore.AI/entry/src/main/cpp/src/utils/napi_error.cpp index 411c40c6fe736fba2d4b41960821361690bc9f08..5a9fef1f89399d71e9f8933ddfb5340ad35385f7 100644 --- a/Mindspore.AI/entry/src/main/cpp/src/utils/napi_error.cpp +++ b/Mindspore.AI/entry/src/main/cpp/src/utils/napi_error.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2024 Unionman Technology Co., Ltd. + * Copyright 2023 Unionman Technology Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/Mindspore.AI/entry/src/main/cpp/src/utils/napi_utils.cpp b/Mindspore.AI/entry/src/main/cpp/src/utils/napi_utils.cpp index 7688af4c73ea2da89a9e51e9f5ba81e701025f23..913fbfdf64283e8e64fae1940527e4607bebba57 100644 --- a/Mindspore.AI/entry/src/main/cpp/src/utils/napi_utils.cpp +++ b/Mindspore.AI/entry/src/main/cpp/src/utils/napi_utils.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2024 Unionman Technology Co., Ltd. + * Copyright 2023 Unionman Technology Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/Mindspore.AI/entry/src/main/cpp/third_party/opencv/BUILD.gn b/Mindspore.AI/entry/src/main/cpp/third_party/opencv/BUILD.gn new file mode 100755 index 0000000000000000000000000000000000000000..c290ae9fbc39201baa960d088e3055ce9b4e05ee --- /dev/null +++ b/Mindspore.AI/entry/src/main/cpp/third_party/opencv/BUILD.gn @@ -0,0 +1,680 @@ +# Copyright 2023 Unionman Technology Co., Ltd. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("//build/config/clang/clang.gni") +import("//build/ohos/ndk/ndk.gni") + +config("opencv_config") { + include_dirs = [ "include/opencv4" ] + cflags = [ + "-Wno-incompatible-pointer-types", + "-Werror", + "-Wimplicit-function-declaration", + "-Wno-error=unused-variable", + ] + cflags = [] +} + +ohos_prebuilt_static_library("libopencv_aruco") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_aruco.a" + } else { + source = "lib/libopencv_aruco.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_barcode") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_barcode.a" + } else { + source = "lib/libopencv_barcode.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" +} + +ohos_prebuilt_static_library("libopencv_bgsegm") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_bgsegm.a" + } else { + source = "lib/libopencv_bgsegm.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_bioinspired") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_bioinspired.a" + } else { + source = "lib/libopencv_bioinspired.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_calib3d") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_calib3d.a" + } else { + source = "lib/libopencv_calib3d.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_ccalib") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_ccalib.a" + } else { + source = "lib/libopencv_ccalib.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_core") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_core.a" + } else { + source = "lib/libopencv_core.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_datasets") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_datasets.a" + } else { + source = "lib/libopencv_datasets.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_dnn_objdetect") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_dnn_objdetect.a" + } else { + source = "lib/libopencv_dnn_objdetect.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_dnn") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_dnn.a" + } else { + source = "lib/libopencv_dnn.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_dnn_superres") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_dnn_superres.a" + } else { + source = "lib/libopencv_dnn_superres.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_dpm") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_dpm.a" + } else { + source = "lib/libopencv_dpm.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_face") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_face.a" + } else { + source = "lib/libopencv_face.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_features2d") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_features2d.a" + } else { + source = "lib/libopencv_features2d.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_flann") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_flann.a" + } else { + source = "lib/libopencv_flann.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_fuzzy") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_fuzzy.a" + } else { + source = "lib/libopencv_fuzzy.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_gapi") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_gapi.a" + } else { + source = "lib/libopencv_gapi.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_hfs") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_hfs.a" + } else { + source = "lib/libopencv_hfs.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_highgui") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_highgui.a" + } else { + source = "lib/libopencv_highgui.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_imgcodecs") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_imgcodecs.a" + } else { + source = "lib/libopencv_imgcodecs.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_img_hash") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_img_hash.a" + } else { + source = "lib/libopencv_img_hash.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_imgproc") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_imgproc.a" + } else { + source = "lib/libopencv_imgproc.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_intensity_transform") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_intensity_transform.a" + } else { + source = "lib/libopencv_intensity_transform.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_line_descriptor") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_line_descriptor.a" + } else { + source = "lib/libopencv_line_descriptor.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_mcc") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_mcc.a" + } else { + source = "lib/libopencv_mcc.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_ml") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_ml.a" + } else { + source = "lib/libopencv_ml.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_objdetect") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_objdetect.a" + } else { + source = "lib/libopencv_objdetect.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_photo") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_photo.a" + } else { + source = "lib/libopencv_photo.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_plot") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_plot.a" + } else { + source = "lib/libopencv_plot.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_text") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_text.a" + } else { + source = "lib/libopencv_text.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_videoio") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_videoio.a" + } else { + source = "lib/libopencv_videoio.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_videostab") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_videostab.a" + } else { + source = "lib/libopencv_videostab.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_video") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_video.a" + } else { + source = "lib/libopencv_video.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_wechat_qrcode") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_wechat_qrcode.a" + } else { + source = "lib/libopencv_wechat_qrcode.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_ximgproc") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_ximgproc.a" + } else { + source = "lib/libopencv_ximgproc.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_xfeatures2d") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_xfeatures2d.a" + } else { + source = "lib/libopencv_xfeatures2d.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_xobjdetect") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_xobjdetect.a" + } else { + source = "lib/libopencv_xobjdetect.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libopencv_xphoto") { + if (target_cpu == "arm64") { + source = "lib64/libopencv_xphoto.a" + } else { + source = "lib/libopencv_xphoto.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +group("opencv") { + deps = [ + ":libopencv_aruco", + ":libopencv_barcode", + ":libopencv_bgsegm", + ":libopencv_bioinspired", + ":libopencv_calib3d", + ":libopencv_ccalib", + ":libopencv_core", + ":libopencv_datasets", + ":libopencv_dnn", + ":libopencv_dnn_objdetect", + ":libopencv_dnn_superres", + ":libopencv_dpm", + ":libopencv_face", + ":libopencv_features2d", + ":libopencv_flann", + ":libopencv_fuzzy", + ":libopencv_gapi", + ":libopencv_hfs", + ":libopencv_highgui", + ":libopencv_img_hash", + ":libopencv_imgcodecs", + ":libopencv_imgproc", + ":libopencv_intensity_transform", + ":libopencv_line_descriptor", + ":libopencv_mcc", + ":libopencv_ml", + ":libopencv_objdetect", + + # ":libopencv_optflow", + # ":libopencv_phase_unwrapping", + ":libopencv_photo", + ":libopencv_plot", + + # ":libopencv_quality", + # ":libopencv_rapid", + # ":libopencv_reg", + # ":libopencv_rgbd", + # ":libopencv_saliency", + # ":libopencv_shape", + # ":libopencv_stereo", + # ":libopencv_stitching", + # ":libopencv_structured_light", + # ":libopencv_superres", + # ":libopencv_surface_matching", + ":libopencv_text", + ":libopencv_video", + + # ":libopencv_tracking", + ":libopencv_videoio", + + ":libopencv_videostab", + ":libopencv_wechat_qrcode", + + ":libopencv_xfeatures2d", + ":libopencv_ximgproc", + ":libopencv_xobjdetect", + ":libopencv_xphoto", + ] +} + +ohos_prebuilt_static_library("libade") { + if (target_cpu == "arm64") { + source = "lib64/opencv4/3rdparty/libade.a" + } else { + source = "lib/opencv4/3rdparty/libade.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libittnotify") { + if (target_cpu == "arm64") { + source = "lib64/opencv4/3rdparty/libittnotify.a" + } else { + source = "lib/opencv4/3rdparty/libittnotify.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("liblibjpeg-turbo") { + if (target_cpu == "arm64") { + source = "lib64/opencv4/3rdparty/liblibjpeg-turbo.a" + } else { + source = "lib/opencv4/3rdparty/liblibjpeg-turbo.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("liblibopenjp2") { + if (target_cpu == "arm64") { + source = "lib64/opencv4/3rdparty/liblibopenjp2.a" + } else { + source = "lib/opencv4/3rdparty/liblibopenjp2.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("liblibpng") { + if (target_cpu == "arm64") { + source = "lib64/opencv4/3rdparty/liblibpng.a" + } else { + source = "lib/opencv4/3rdparty/liblibpng.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("liblibprotobuf") { + if (target_cpu == "arm64") { + source = "lib64/opencv4/3rdparty/liblibprotobuf.a" + } else { + source = "lib/opencv4/3rdparty/liblibprotobuf.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("liblibtiff") { + if (target_cpu == "arm64") { + source = "lib64/opencv4/3rdparty/liblibtiff.a" + } else { + source = "lib/opencv4/3rdparty/liblibtiff.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("liblibwebp") { + if (target_cpu == "arm64") { + source = "lib64/opencv4/3rdparty/liblibwebp.a" + } else { + source = "lib/opencv4/3rdparty/liblibwebp.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libquirc") { + if (target_cpu == "arm64") { + source = "lib64/opencv4/3rdparty/libquirc.a" + } else { + source = "lib/opencv4/3rdparty/libquirc.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +ohos_prebuilt_static_library("libtegra_hal") { + if (target_cpu == "arm64") { + source = "lib64/opencv4/3rdparty/libtegra_hal.a" + } else { + source = "lib/opencv4/3rdparty/libtegra_hal.a" + } + public_configs = [ ":opencv_config" ] + + part_name = "rockchip_products" + +} + +group("opencv_3rdparty") { + deps = [ + ":libade", + ":libittnotify", + ":liblibjpeg-turbo", + ":liblibopenjp2", + ":liblibpng", + ":liblibprotobuf", + ":liblibtiff", + ":liblibwebp", + ":libquirc", + ":libtegra_hal", + ] +} diff --git a/Mindspore.AI/entry/src/main/cpp/types/libmslite_napi/index.d.ts b/Mindspore.AI/entry/src/main/cpp/types/libmslite_napi/index.d.ts index c2e62db83c953a9ca692c63d486772b947e892c1..2d702fa1e9e8fcd5c909b17f69e12b01fb8c1912 100644 --- a/Mindspore.AI/entry/src/main/cpp/types/libmslite_napi/index.d.ts +++ b/Mindspore.AI/entry/src/main/cpp/types/libmslite_napi/index.d.ts @@ -1,5 +1,5 @@ /* - * Copyright 2024 Unionman Technology Co., Ltd. + * Copyright 2023 Unionman Technology Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/Mindspore.AI/entry/src/main/cpp/types/libmslite_napi/oh-package.json5 b/Mindspore.AI/entry/src/main/cpp/types/libmslite_napi/oh-package.json5 index 61725f34ee72d082562c0b196762efc9116b50a5..1e81537f74fe791f01c4ee186d682bc6e463ab68 100644 --- a/Mindspore.AI/entry/src/main/cpp/types/libmslite_napi/oh-package.json5 +++ b/Mindspore.AI/entry/src/main/cpp/types/libmslite_napi/oh-package.json5 @@ -1,5 +1,5 @@ /* - * Copyright 2024 Unionman Technology Co., Ltd. + * Copyright 2023 Unionman Technology Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/Mindspore.AI/entry/src/main/ets/entryability/EntryAbility.ts b/Mindspore.AI/entry/src/main/ets/entryability/EntryAbility.ts index f3f0b3d5535d6f00ba2b6fb9b086f56d8912eec4..d1947252e2d353c6944cb51dcd694e814bce2ed9 100644 --- a/Mindspore.AI/entry/src/main/ets/entryability/EntryAbility.ts +++ b/Mindspore.AI/entry/src/main/ets/entryability/EntryAbility.ts @@ -1,5 +1,5 @@ /* - * Copyright 2024 Unionman Technology Co., Ltd. + * Copyright 2023 Unionman Technology Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/Mindspore.AI/entry/src/main/ets/model/CameraModel.ets b/Mindspore.AI/entry/src/main/ets/model/CameraModel.ets index 70eafdbb2149ad2a87d65964980c8ba1a6ec68cb..77d08b89af33d2b1e57e93a16434f12d0399b3cf 100644 --- a/Mindspore.AI/entry/src/main/ets/model/CameraModel.ets +++ b/Mindspore.AI/entry/src/main/ets/model/CameraModel.ets @@ -1,5 +1,5 @@ /* - * Copyright 2024 Unionman Technology Co., Ltd. + * Copyright 2023 Unionman Technology Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -155,8 +155,8 @@ export default class CameraService { } let picDesc: PicDesc = { - width: 1080, - height: 1920, + width: 960, + height: 1280, dataSize: buffer.byteLength } @@ -170,6 +170,7 @@ export default class CameraService { }); } Logger.info(TAG, `number = ${number}`); + //Logger.info(TAG, `buffer.byteLength = ${buffer.byteLength}`); number ++; nextImage.release(); }) diff --git a/Mindspore.AI/entry/src/main/ets/pages/Index.ets b/Mindspore.AI/entry/src/main/ets/pages/Index.ets index 3b34b98c348e358ba5e40fe60e9faed9e65cdede..9c2b6ad9fd2afe96b9d74af46f6a6a9394e84f58 100644 --- a/Mindspore.AI/entry/src/main/ets/pages/Index.ets +++ b/Mindspore.AI/entry/src/main/ets/pages/Index.ets @@ -1,5 +1,5 @@ /* - * Copyright 2024 Unionman Technology Co., Ltd. + * Copyright 2023 Unionman Technology Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -75,7 +75,6 @@ struct CameraPage { @State modelId: number = 0; @State pointData: ObjectDesc[] = []; @State imageNumber: number = 0; - @State count: number = 0; private context: Context = getContext(this); async aboutToAppear() { @@ -91,7 +90,6 @@ struct CameraPage { let resourceManager = context.resourceManager; mslite_napi.DeInit(); try { - console.log('1433223' + JSON.stringify(this.count)); this.modelId = mslite_napi.Init(resourceManager); // this.modelId = mslite_napi.Init(modelPath); Logger.info(TAG ,`modelId = ${this.modelId.toString()}`) @@ -109,7 +107,6 @@ struct CameraPage { this.pointData = value; }) Logger.info(TAG, `aboutToAppear,surfaceId=${this.surfaceId}`); - this.count ++ } onPageHide() { @@ -151,7 +148,7 @@ struct CameraPage { .fontSize(12) .fontColor(this.colorSet[index % 4]) } - .position({ x: px2vp(1080 - item.bottom), y: px2vp(item.left) }) + .position({ x: px2vp(960 - item.bottom), y: px2vp(item.left) }) .width(px2vp((item.bottom - item.top))) .height(px2vp((item.right - item.left))) .borderWidth(2) @@ -174,12 +171,12 @@ struct CameraPage { this.pointData = value; }) }) - .width('1080px') - .height('1920px') + .width('960px') + .height('1280px') }.zIndex(0) } - .width('1080px') - .height('1920px') + .width('960px') + .height('1280px') } .justifyContent(FlexAlign.Center) .backgroundColor('#000000') diff --git a/Mindspore.AI/entry/src/main/ets/utlis/Logger.ts b/Mindspore.AI/entry/src/main/ets/utlis/Logger.ts index 667fb7ef8d0b34b09350b2ba6a4d28be35a8d4b9..e9fd0542f7d838bea5833c9209b2126856d3c898 100644 --- a/Mindspore.AI/entry/src/main/ets/utlis/Logger.ts +++ b/Mindspore.AI/entry/src/main/ets/utlis/Logger.ts @@ -1,5 +1,5 @@ /* - * Copyright 2024 Unionman Technology Co., Ltd. + * Copyright 2023 Unionman Technology Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/Mindspore.AI/entry/src/main/ets/utlis/PermissionUtils.ets b/Mindspore.AI/entry/src/main/ets/utlis/PermissionUtils.ets index cfed53ae0e61604ec52ffb6a26e16baaee42f283..497bd79273d47a105bee33d4c0ede5d5b5b17409 100644 --- a/Mindspore.AI/entry/src/main/ets/utlis/PermissionUtils.ets +++ b/Mindspore.AI/entry/src/main/ets/utlis/PermissionUtils.ets @@ -1,5 +1,5 @@ /* - * Copyright 2024 Unionman Technology Co., Ltd. + * Copyright 2023 Unionman Technology Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at