diff --git a/zbar/BUILD.gn b/zbar/BUILD.gn new file mode 100644 index 0000000000000000000000000000000000000000..0767cdf663516669f03e6e6c00ffb7aa4e54bce4 --- /dev/null +++ b/zbar/BUILD.gn @@ -0,0 +1,94 @@ +import("//build/ohos.gni") + +declare_args() { + enable_zbar_test = false +} + +config("config") { + cflags = [ + "-O3", + "-Wall", + "-Wno-extra-tokens", + "-Wno-incompatible-pointer-types", + "-Wno-parentheses", + "-Wno-unused-variable", + "-Wno-absolute-value", + "-Wno-unused-function", + "-Wno-unused-const-variable", + "-Wno-unused-label", + "-Wno-shift-negative-value", + "-Wno-tautological-pointer-compare", + "-Wno-duplicate-decl-specifier", + ] +} + +ohos_source_set("zbar_source") { + sources = [ + "//third_party/zbar/zbar/config.c", + "//third_party/zbar/zbar/convert.c", + "//third_party/zbar/zbar/decoder.c", + "//third_party/zbar/zbar/decoder/code128.c", + "//third_party/zbar/zbar/decoder/code39.c", + "//third_party/zbar/zbar/decoder/ean.c", + "//third_party/zbar/zbar/decoder/i25.c", + "//third_party/zbar/zbar/decoder/pdf417.c", + "//third_party/zbar/zbar/decoder/qr_finder.c", + "//third_party/zbar/zbar/error.c", + "//third_party/zbar/zbar/image.c", + "//third_party/zbar/zbar/img_scanner.c", + "//third_party/zbar/zbar/jpeg.c", + "//third_party/zbar/zbar/qrcode/bch15_5.c", + "//third_party/zbar/zbar/qrcode/binarize.c", + "//third_party/zbar/zbar/qrcode/isaac.c", + "//third_party/zbar/zbar/qrcode/qrdec.c", + "//third_party/zbar/zbar/qrcode/qrdectxt.c", + "//third_party/zbar/zbar/qrcode/rs.c", + "//third_party/zbar/zbar/qrcode/util.c", + "//third_party/zbar/zbar/refcnt.c", + "//third_party/zbar/zbar/scanner.c", + "//third_party/zbar/zbar/symbol.c", + "//third_party/zbar/zbar/video.c", + "//third_party/zbar/zbar/video/null.c", + ] + include_dirs = [ + "//third_party/zbar/include", + "//third_party/libjpeg", + "//third_party/libpng", + "//third_party/zbar/zbar/", + ] + configs = [ ":config" ] +} + +ohos_executable("zbar_test") { + sources = [ "//third_party/zbar/examples/scan_image.c" ] + include_dirs = [ + "//third_party/zbar/include", + "//third_party/libjpeg", + "//third_party/libpng", + "//third_party/zbar/zbar/", + ] + + configs = [ ":config" ] + + deps = [ "//third_party/zbar:libzbar" ] + subsystem_name = "thirdparty" + part_name = "zbar" + output_name = "zbar_test" +} + +ohos_shared_library("libzbar") { + deps = [ + ":zbar_source", + "//third_party/libjpeg:libjpeg_static", + "//third_party/libpng:libpng_static", + ] + part_name = "zbar" + output_name = "zbar" +} + +group("zbar_targets") { + deps = [ ":libzbar" ] + if (enable_zbar_test) { + deps += [ ":zbar_test" ] + } +} diff --git a/zbar/CHANGELOG.md b/zbar/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..4963dc7546e7cc84baf8e836c544ddf43f554025 --- /dev/null +++ b/zbar/CHANGELOG.md @@ -0,0 +1,3 @@ +# 1.0.0 + +添加BUILD.gn和cmake,适配在ohos上的编译 diff --git a/zbar/CMakeLists.txt b/zbar/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..6299ab8c622d7d876a6d77efde6fba8ac686a9b6 --- /dev/null +++ b/zbar/CMakeLists.txt @@ -0,0 +1,55 @@ +# the minimum version of CMake. +cmake_minimum_required(VERSION 3.4.1) +project(ZBar) + +include_directories(${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${CMAKE_CURRENT_SOURCE_DIR}/zbar + ${CMAKE_CURRENT_SOURCE_DIR}/third_party_libjpeg + ${CMAKE_CURRENT_SOURCE_DIR}/third_party_libpng + ) + +add_subdirectory(third_party_libjpeg) +add_subdirectory(third_party_libpng) + +add_library(ZBar SHARED + zbar/jpeg.c + zbar/img_scanner.c + zbar/decoder.c + zbar/image.c + zbar/symbol.c + zbar/convert.c + zbar/config.c + zbar/scanner.c + zbar/error.c + zbar/refcnt.c + zbar/video.c + zbar/video/null.c + zbar/decoder/code128.c + zbar/decoder/code39.c + zbar/decoder/ean.c + zbar/decoder/i25.c + zbar/decoder/qr_finder.c + zbar/decoder/pdf417.c + zbar/qrcode/bch15_5.c + zbar/qrcode/binarize.c + zbar/qrcode/isaac.c + zbar/qrcode/qrdec.c + zbar/qrcode/qrdectxt.c + zbar/qrcode/rs.c + zbar/qrcode/util.c + ) + +add_library(libjpegStatic STATIC IMPORTED) +set_target_properties(libjpegStatic PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/third_party_libjpeg/libs/${OHOS_ARCH}/libjpegStatic.a) + +add_library(libpngStatic STATIC IMPORTED) +set_target_properties(libpngStatic PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/third_party_libpng/libs/${OHOS_ARCH}/libpngStatic.a) + + +target_link_libraries(ZBar PUBLIC libjpegStatic) +target_link_libraries(ZBar PUBLIC libpngStatic) +target_link_libraries(ZBar PUBLIC libz.so) + +add_executable(scan_image examples/scan_image.c) +target_link_libraries(scan_image PUBLIC ZBar) \ No newline at end of file diff --git a/zbar/README.OpenSource b/zbar/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..9105ee6ed069d317c156313f1e74c1616ae84524 --- /dev/null +++ b/zbar/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "zbar", + "License": "LGPL", + "License File": "COPYING", + "Version Number": "master", + "Owner" : "wupingyuan@huawei.com", + "Upstream URL": "https://github.com/herbyme/zbar", + "Description": "libzbar, a QR Code scanner engine for QR+Emoji." + } +] diff --git a/zbar/README_zh.md b/zbar/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..a7a4c1ccc34ffbd48069601ad672ce2ede867b8e --- /dev/null +++ b/zbar/README_zh.md @@ -0,0 +1,19 @@ +# zbar 三方库说明 + +## 功能简介 + +zbar是一个条形码和二维码解析的库。 + +## 使用约束 + +- Rom版本:OpenHarmony3.2 beta2 +- IDE版本:DevEco Studio 3.1 Beta1 +- API版本:9 +- 三方库版本:0.10 +- 当前适配的功能:条形码和二维码解析 +- License:[LGPL](https://github.com/herbyme/zbar/blob/master/COPYING) + +## 集成方式 + +- [系统Rom包集成](./docs/rom_integrate.md) ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/zbar/adapted/config.h b/zbar/adapted/config.h new file mode 100644 index 0000000000000000000000000000000000000000..e62bd003e7b3238914fab30b57ecebd9e546c587 --- /dev/null +++ b/zbar/adapted/config.h @@ -0,0 +1,227 @@ +/* include/config.h.in. Generated from configure.ac by autoheader. */ + +/* whether to build support for Code 128 symbology */ +#define ENABLE_CODE128 1 + +/* whether to build support for Code 39 symbology */ +#define ENABLE_CODE39 1 + +/* whether to build support for EAN symbologies */ +#define ENABLE_EAN 1 + +/* whether to build support for Interleaved 2 of 5 symbology */ +#define ENABLE_I25 1 + +/* whether to build support for PDF417 symbology */ +#define ENABLE_PDF417 1 + +/* whether to build support for QR Code */ +#define ENABLE_QRCODE 1 + +/* Define to 1 if you have the `atexit' function. */ +#undef HAVE_ATEXIT + +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_FEATURES_H + +/* Define to 1 if you have the `getpagesize' function. */ +#undef HAVE_GETPAGESIZE + +/* Define if you have the iconv() function and it works. */ +#undef HAVE_ICONV + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_JPEGLIB_H + +/* Define to 1 if you have the `jpeg' library (-ljpeg). */ +//#undef HAVE_LIBJPEG +#define HAVE_LIBJPEG 1 + + +/* Define to 1 if you have the `pthread' library (-lpthread). */ +#undef HAVE_LIBPTHREAD + +/* Define to 1 if you have the header file. */ +#undef HAVE_LINUX_VIDEODEV2_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LINUX_VIDEODEV_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the `memset' function. */ +#define HAVE_MEMSET 1 + +/* Define to 1 if you have a working `mmap' system call. */ +#undef HAVE_MMAP + +/* Define to 1 if you have the header file. */ +#undef HAVE_POLL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_PTHREAD_H + +/* Define to 1 if you have the `setenv' function. */ +#undef HAVE_SETENV + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_IOCTL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_IPC_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_MMAN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SHM_H + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIMES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TIME_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if the system has the type `uintptr_t'. */ +#define HAVE_UINTPTR_T 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if you have the header file. */ +#undef HAVE_VFW_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_X11_EXTENSIONS_XSHM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_X11_EXTENSIONS_XVLIB_H + +/* Define as const if the declaration of iconv() needs const. */ +#undef ICONV_CONST + +/* Library major version */ +#define LIB_VERSION_MAJOR 0 + +/* Library minor version */ +#define LIB_VERSION_MINOR 2 + +/* Library revision */ +#define LIB_VERSION_REVISION 0 + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#undef LT_OBJDIR + +/* Define to 1 if assertions should be disabled. */ +//#undef NDEBUG + +/* Define to 1 if your C compiler doesn't accept -c and -o together. */ +#undef NO_MINUS_C_MINUS_O + +/* Name of package */ +#undef PACKAGE "zbar" + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT "spadix@users.sourceforge.net" + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME "zbar" + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING "zbar 0.10" + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME "zbar" + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION "0.10" + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Version number of package */ +#undef VERSION "0.10" + +/* Define to 1 if the X Window System is missing or not being used. */ +#define X_DISPLAY_MISSING 1 + +/* Program major version (before the '.') as a number */ +#define ZBAR_VERSION_MAJOR 0 + +/* Program minor version (after '.') as a number */ +#define ZBAR_VERSION_MINOR 10 + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +#undef _UINT32_T + +/* Define for Solaris 2.5.1 so the uint8_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +#undef _UINT8_T + +/* Minimum Windows API version */ +#undef _WIN32_WINNT + +/* used only for pthread debug attributes */ +#undef __USE_UNIX98 + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +#undef inline +#endif + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +#undef int32_t + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +#undef uint32_t + +/* Define to the type of an unsigned integer type of width exactly 8 bits if + such a type exists and the standard includes do not define it. */ +#undef uint8_t + +/* Define to the type of an unsigned integer type wide enough to hold a + pointer, if such a type exists, and if the system does not define it. */ +#undef uintptr_t + +#ifndef X_DISPLAY_MISSING +# define HAVE_X +#endif + diff --git a/zbar/adapted/third_party_libjpeg/CMakeLists.txt b/zbar/adapted/third_party_libjpeg/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..f11ffa9511cb96eb9959d968f53521f77ae6c034 --- /dev/null +++ b/zbar/adapted/third_party_libjpeg/CMakeLists.txt @@ -0,0 +1,110 @@ +cmake_minimum_required(VERSION 3.16.5) + +project(third_party_libjpeg) + +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/libs/${OHOS_ARCH}) + +set(LibjpegSrc "${PROJECT_SOURCE_DIR}") + +include_directories(${LibjpegSrc}) + +include(CheckIncludeFile) +include(CheckSymbolExists) +include(CheckCSourceCompiles) + +check_include_file(stddef.h HAVE_STDDEF_H) +check_include_file(stdlib.h HAVE_STDLIB_H) +check_include_file(string.h HAVE_STRING_H) +check_symbol_exists(size_t stddef.h stdlib.h stdio.h HAVE_ANSI_SIZE_T) +check_symbol_exists(setmode io.h USE_SETMODE) +check_c_source_compiles( +" +void f() +{ + char x[ (char)0xff ]; /* x[-1] if signed */ +} +" +CHAR_IS_UNSIGNED) + +check_c_source_compiles( +" +void f() +{ + char x[ ((signed char)0xff) >> 1 ]; /* x[-1] if signed */ +} +" +RIGHT_SHIFT_IS_UNSIGNED) + +if(NOT HAVE_STRING_H) + set(NEED_BSD_STRINGS TRUE) +else() + set(NEED_BSD_STRINGS FALSE) +endif() + +if(NOT HAVE_ANSI_SIZE_T) + set(NEED_SYS_TYPES_H TRUE) +else() + set(NEED_SYS_TYPES_H FALSE) +endif() + +configure_file(${LibjpegSrc}/jconfig.txt ${LibjpegSrc}/jconfig.h) + +add_library(jpegStatic STATIC + ${LibjpegSrc}/cdjpeg.c + ${LibjpegSrc}/jaricom.c + ${LibjpegSrc}/jcapimin.c + ${LibjpegSrc}/jcapistd.c + ${LibjpegSrc}/jcarith.c + ${LibjpegSrc}/jccoefct.c + ${LibjpegSrc}/jccolor.c + ${LibjpegSrc}/jcdctmgr.c + ${LibjpegSrc}/jchuff.c + ${LibjpegSrc}/jcinit.c + ${LibjpegSrc}/jcmainct.c + ${LibjpegSrc}/jcmarker.c + ${LibjpegSrc}/jcmaster.c + ${LibjpegSrc}/jcomapi.c + ${LibjpegSrc}/jcparam.c + ${LibjpegSrc}/jcprepct.c + ${LibjpegSrc}/jcsample.c + ${LibjpegSrc}/jctrans.c + ${LibjpegSrc}/jdapimin.c + ${LibjpegSrc}/jdapistd.c + ${LibjpegSrc}/jdarith.c + ${LibjpegSrc}/jdatadst.c + ${LibjpegSrc}/jdatasrc.c + ${LibjpegSrc}/jdcoefct.c + ${LibjpegSrc}/jdcolor.c + ${LibjpegSrc}/jddctmgr.c + ${LibjpegSrc}/jdhuff.c + ${LibjpegSrc}/jdinput.c + ${LibjpegSrc}/jdmainct.c + ${LibjpegSrc}/jdmarker.c + ${LibjpegSrc}/jdmaster.c + ${LibjpegSrc}/jdmerge.c + ${LibjpegSrc}/jdpostct.c + ${LibjpegSrc}/jdsample.c + ${LibjpegSrc}/jdtrans.c + ${LibjpegSrc}/jerror.c + ${LibjpegSrc}/jfdctflt.c + ${LibjpegSrc}/jfdctfst.c + ${LibjpegSrc}/jfdctint.c + ${LibjpegSrc}/jidctflt.c + ${LibjpegSrc}/jidctfst.c + ${LibjpegSrc}/jidctint.c + ${LibjpegSrc}/jmemansi.c + ${LibjpegSrc}/jmemmgr.c + ${LibjpegSrc}/jquant1.c + ${LibjpegSrc}/jquant2.c + ${LibjpegSrc}/jutils.c + ${LibjpegSrc}/rdbmp.c + ${LibjpegSrc}/rdcolmap.c + ${LibjpegSrc}/rdgif.c + ${LibjpegSrc}/rdppm.c + ${LibjpegSrc}/rdrle.c + ${LibjpegSrc}/rdswitch.c + ${LibjpegSrc}/rdtarga.c + ${LibjpegSrc}/transupp.c + ) + +target_include_directories(jpegStatic PUBLIC ${LibjpegSrc}) diff --git a/zbar/adapted/third_party_libpng/CMakeLists.txt b/zbar/adapted/third_party_libpng/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..18a8afcd294902d165583f5108c97dd864f78631 --- /dev/null +++ b/zbar/adapted/third_party_libpng/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 3.4.1) +project(third_party_libpng) + +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/libs/${OHOS_ARCH}) + +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + +add_library(pngStatic STATIC + arm/arm_init.c + arm/filter_neon_intrinsics.c + arm/palette_neon_intrinsics.c + png.c + pngerror.c + pngget.c + pngmem.c + pngpread.c + pngread.c + pngrio.c + pngrtran.c + pngrutil.c + pngset.c + pngtrans.c + pngwio.c + pngwrite.c + pngwtran.c + pngwutil.c) + + diff --git a/zbar/bundle.json b/zbar/bundle.json new file mode 100644 index 0000000000000000000000000000000000000000..bd5578ba20422ebcb125b7ed4cda27d82895fa30 --- /dev/null +++ b/zbar/bundle.json @@ -0,0 +1,35 @@ +{ + "name": "@ohos/zbar", + "description": "libzbar, a QR Code scanner engine for QR+Emoji", + "version": "0.10", + "license": "LGPL-2.1", + "publishAs": "", + "segment": { + "destPath": "third_party/zbar" + }, + "dirs": {}, + "scripts": {}, + "readmePath": { + "en": "README" + }, + "component": { + "name": "zbar", + "subsystem": "thirdparty", + "syscap": [], + "features": [], + "adapted_system_type": ["standard"], + "rom": "", + "ram": "", + "deps": { + "components": [], + "third_party": [] + }, + "build": { + "sub_component": [ + "//third_party/zbar:zbar_targets" + ], + "inner_kits": [], + "test": [] + } + } +} \ No newline at end of file diff --git a/zbar/docs/hap_integrate.md b/zbar/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..af76a2673494056770af51388543414cdee7dd82 --- /dev/null +++ b/zbar/docs/hap_integrate.md @@ -0,0 +1,55 @@ +# zbar如何集成到应用hap +## 准备应用工程 +本库是基于DevEco Studio 3.1 Beta1版本,在RK3568开发板上验证的,如果是从未使用过RK3568,可以先查看[润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld)。 +### 准备应用开发环境 +开发环境的准备参考:[开发环境准备](https://gitee.com/openharmony-sig/knowledge_demo_temp/blob/master/docs/napi_study/docs/hello_napi.md#%E5%B7%A5%E7%A8%8B%E5%87%86%E5%A4%87) +### 增加构建脚本及配置文件 +- 下载本仓库,并解压 +- 三方库目录结构 + ``` + tpc_c_cplusplus/zbar #三方库zbar的目录结构如下 + ├── adapted #存放三方库适配需要的代码文件 + ├── docs #存放三方库相关文档的文件夹 + ├── CmakeLists.txt #构建脚本,支持hap包集成 + ├── bundle.json #三方库组件定义文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` +- 将zbar拷贝至工程xxxx/entry/src/main/cpp/thirdparty目录下 +### 准备三方库源码 +- 三方库下载地址:[zbar](https://github.com/herbyme/zbar) + 解压后修改库文件名为zbar,拷贝至工程xxxx/entry/src/main/cpp/thirdparty/zbar目录下 +- 依赖库下载地址:[third_party_libpng](https://gitee.com/openharmony/third_party_libpng) + 解压后修改库文件名为third_party_libpng,拷贝至工程xxxx/entry/src/main/cpp/thirdparty/zbar/目录下,然后把adapter/third_party_libpng/CMakeLists.txt拷贝到third_party_libpng目录 +- 依赖库下载地址:[third_party_libjpeg](https://gitee.com/openharmony/third_party_libjpeg) + 解压后修改库文件名为third_party_libjpeg,拷贝至工程xxxx/entry/src/main/cpp/thirdparty/zbar/目录下,然后把adapter/third_party_libjpeg/CMakeLists.txt拷贝到third_party_libjpeg目录 +## 应用中使用三方库 +- 将三方库加入工程中,目录结构如下 + ``` + demo/entry/src/main/cpp + ├── thirdparty #三方库存放目录 + │ ├── zbar #三方库zbar + ├── CMakeLists.txt #工程目录的构建脚本 + ├── ..... #工程目录的其他文件 + ``` +- 在工程顶级CMakeLists.txt中引入三方库,增加如下代码 + ``` + add_subdirectory(thirdparty/zbar) #引入子目录下的CMakeLists.txt + target_link_libraries(工程库名 PUBLIC zbar) #工程依赖三方库zbar + target_include_directories(工程库名 PRIVATE thirdparty/zbar/third_party_libjpeg + thirdparty/zbar/third_party_libpng + thirdparty/zbar/include) + ``` +## 编译工程 +编译工程,安装应用可以参考 [应用的安装和运行](https://gitee.com/openharmony-sig/knowledge_demo_temp/blob/master/docs/napi_study/docs/hello_napi.md#%E5%AE%89%E8%A3%85%E8%B0%83%E8%AF%95) + +## 运行效果 +- 在 [zbar](https://gitee.com/openharmony-tpc/openharmony_tpc_samples/tree/master/zbar)中,运行效果如下图 +  ![演示](pic/hap.jpg) +## 参考资料 +- [润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld) +- [OpenHarmony三方库地址](https://gitee.com/openharmony-tpc) +- [OpenHarmony知识体系](https://gitee.com/openharmony-sig/knowledge) +- [通过DevEco Studio开发一个NAPI工程](https://gitee.com/openharmony-sig/knowledge_demo_temp/blob/master/docs/napi_study/docs/hello_napi.md) + + diff --git a/zbar/docs/pic/hap.jpg b/zbar/docs/pic/hap.jpg new file mode 100644 index 0000000000000000000000000000000000000000..3e84f208091d744400ded1166a7c5e3290fbc226 Binary files /dev/null and b/zbar/docs/pic/hap.jpg differ diff --git a/zbar/docs/pic/result.png b/zbar/docs/pic/result.png new file mode 100644 index 0000000000000000000000000000000000000000..ecbdaadcc60d420c2326f2a78d7d0f66185545ee Binary files /dev/null and b/zbar/docs/pic/result.png differ diff --git a/zbar/docs/rom_integrate.md b/zbar/docs/rom_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..ab4a11965d76486fa5f496a20234b044fd189fcc --- /dev/null +++ b/zbar/docs/rom_integrate.md @@ -0,0 +1,143 @@ +# zbar如何集成到系统Rom + +## 准备源码工程 + +本库是基于OpenHarmony-v3.2-Beta2版本,在RK3568开发板上验证的,如果是从未使用过RK3568,可以先查看[润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld)。 + +### 准备系统Rom源码 + +系统源码获取请参考:[OpenHarmony源码下载](https://gitee.com/openharmony/docs/blob/OpenHarmony-v3.2-Beta3/zh-cn/release-notes/OpenHarmony-v3.2-beta2.md) + +### 增加构建脚本及配置文件 + +- 下载本仓库代码 + + ``` + cd ~ + git clone git@gitee.com:openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` + +- 三方库目录结构 + + ``` + tpc_c_cplusplus/zbar #三方库zbar的目录结构如下 + ├── adapted #存放三方库适配需要的代码文件 + ├── docs #存放三方库相关文档的文件夹 + ├── BUILD.gn #构建脚本,支持rom包集成 + ├── bundle.json #三方库组件定义文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` + +- 将三方库拷贝到OpenHarmony源码的third_party目录下 + + ``` + cp ~/tpc_c_cplusplus/zbar ~/openharmony/third_party -rf + ``` + +### 准备三方库源码 + +``` +cd ~/openharmony/third_party/zbar #进入三方库目录 +git clone https://github.com/zbar/zbar.git #下载三方库源码 +``` + +## 系统Rom中引入三方库 + +准备完三方库代码后,我们需要将三方库加入到编译构建体系中。标准系统编译构建可以参考文档[标准系统编译构建指导](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Beta1/zh-cn/device-dev/subsystems/subsys-build-standard-large.md) 我们默认三方库是属于OpenHarmony的thirdparty子系统,如果需要自己定义子系统参考文档[如何为三方库组件中添加一个三方库](https://gitee.com/openharmony-sig/knowledge/blob/master/docs/openharmony_getstarted/port_thirdparty/README.md) 新增需要编译的组件,在OpenHarmony源码的vendor/hihope/rk3568/config.json文件中,新增需要编译的组件,如下代码段所示,在thirdparty子系统下面新增zbar组件 + +``` + { + "subsystem": "thirdparty", + "components": [ + { + "component": "musl", + "features": [] + }, + { + "component": "zbar", + "features": [] + } + ] + } +``` + +## 系统Rom中引入三方库测试程序 + +zbar原生库提供了测试用例,如需要引入测试程序,在OpenHarmony源码的vendor/hihope/rk3568/config.json文件,对应组件的features中打开编译选项: + +``` +{ + "subsystem": "thirdparty", + "components": [ + { + "component": "musl", + "features": [] + }, + { + "component": "zbar", + "features": [ "enable_zbar_test=true" ] + } + ] +} +``` + +## 编译工程 + +在OpenHarmony源码根目录下 + +``` +cd ~/openharmony +``` + +- 执行编译 + + ``` + ./build.sh --product-name rk3568 --ccache + ``` + +- 生成文件的路径 + + 可执行文件和库生成在out/rk3568/thirdparty/zbar + +## 运行效果 + +将编译生成的库和测试文件放到板子上运行,为避免每次将文件推入设备都烧录整个镜像,我们使用hdc_std工具将文件推到开发板上 + +- 首先将hdc_std工具编译出来 工具编译出来所在路径out/sdk/ohos-sdk/windows/toolchains/hdc_std.exe + + ``` + hb set #源码根目录下使用hb set 选择产品ohos-sdk + hb build #然后编译 + ``` + +- 将工具拷贝到Windows,可以为工具目录配置环境变量,也可以在工具所在目录打开windows命令行 + +- 将编译生成的zbar_test可执行文件和二维码、条形码素材qrcode.png、barcode.png准备好 + +- 将准备好的文件推送到开发板,在windows命令行进行如下操作 + + ``` + hdc_std shell mount -o remount,rw / #修改系统权限为可读写 + hdc_std file send zbar_test /data #将可执行文件推入开发板data目录 + hdc_std file send libzbar.z.so /system/lib64 + hdc_std file send libzbar.z.so /system/lib + hdc_std file send qrcode.png /data #将测试文件推入开发板data目录 + hdc_std file send barcode.png /data #将测试文件推入开发板data目录 + hdc_std shell #进入开发板 + chmod 777 zbar_test #添加权限 + ./zbar_test barcode.png #条形码解析 + ./zbar_test qrcode.png #二维码解析 + ``` + +- 运行测试程序 效果如下图 + +- ![result](pic/result.png) + +## 参考资料 + +- [润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld) +- [OpenHarmony三方库地址](https://gitee.com/openharmony-tpc) +- [OpenHarmony知识体系](https://gitee.com/openharmony-sig/knowledge) +- [如何为三方库组件中添加一个三方库](https://gitee.com/openharmony-sig/knowledge/blob/master/docs/openharmony_getstarted/port_thirdparty/README.md) +- [标准系统编译构建指导](https://gitee.com/openharmony/docs/blob/OpenHarmony-3.2-Beta1/zh-cn/device-dev/subsystems/subsys-build-standard-large.md) \ No newline at end of file