hzt_asc 1.0.8 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CMakeLists.txt CHANGED
@@ -1,6 +1,13 @@
1
1
  cmake_minimum_required(VERSION 3.3)
2
2
  cmake_policy(SET CMP0042 NEW)
3
3
  set (CMAKE_CXX_STANDARD 11)
4
+ #set(CMAKE_VERBOSE_MAKEFILE ON)
5
+
6
+ #set(CMAKE_SKIP_BUILD_RPATH FALSE)
7
+ #set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
8
+ #set(CMAKE_INSTALL_RPATH $ORIGIN)
9
+ #set(CMAKE_PREFIX_PATH "/home/myusername/Documents/mylibleveldb")
10
+ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
4
11
 
5
12
  project (hzt_asc_v3)
6
13
 
@@ -8,31 +15,37 @@ find_package( OpenCV REQUIRED )
8
15
  include_directories( ${OpenCV_INCLUDE_DIRS} )
9
16
  include_directories(${CMAKE_JS_INC})
10
17
 
11
- #find_library(SERIALDEVICE_LIB arcsoft_face)
18
+ #message(status " This is the OpenCV_INCLUDE_DIRS srcs:" ${OpenCV_INCLUDE_DIRS})
19
+ #message(status " This is the OpenCV_LIBS srcs:" ${OpenCV_LIBS})
20
+ #message(status " This is the CMAKE_JS_INC srcs:" ${CMAKE_JS_INC})
21
+ #message(status " This is the CMAKE_JS_LIB srcs:" ${CMAKE_JS_LIB})
22
+
12
23
 
13
24
  #指定头文件目录
14
25
  include_directories(./)
15
26
  include_directories(./inc)
16
27
  #指定静态和动态文件目录
17
- link_directories(linux_so)
18
- link_directories(lib)
19
- aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} SRC)
28
+ link_directories(./linux_so)
20
29
 
30
+
31
+ aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} SRC)
21
32
  add_library(${PROJECT_NAME} SHARED ${SRC} ${CMAKE_JS_SRC})
22
33
 
23
34
 
24
35
 
36
+ find_library(ARC_LIBRARY arcsoft_face HINTS ${CMAKE_CURRENT_SOURCE_DIR}/linux_so)
37
+ message(status " This is the ARC_LIBRARY srcs:" ${ARC_LIBRARY})
25
38
 
26
39
  #链接库文件
27
- target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB})
40
+ #target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB})
28
41
 
29
- target_link_libraries(${PROJECT_NAME} arcsoft_face)
30
- #link_directories(./so)
31
- target_link_libraries(${PROJECT_NAME} arcsoft_face_engine)
42
+ #target_link_libraries(${PROJECT_NAME} -larcsoft_face)
43
+ target_link_libraries(${PROJECT_NAME} -larcsoft_face_engine)
32
44
 
45
+ target_link_libraries(${PROJECT_NAME} ${ARC_LIBRARY})
33
46
 
34
47
  target_link_libraries(${PROJECT_NAME} curl)
35
- target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS} )
48
+ target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS})
36
49
 
37
50
  set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
38
51
  # Include Node-API wrappers
package/ask.cc CHANGED
@@ -579,8 +579,6 @@ Napi::Value ASK::ImageFaceCompareUrl2(const Napi::CallbackInfo& info) {
579
579
  return obj;
580
580
  }
581
581
 
582
-
583
-
584
582
  Napi::Value ASK::ImageFaceCompareUrl(const Napi::CallbackInfo& info) {
585
583
  Napi::Env env = info.Env();
586
584
  int length = info.Length();
@@ -633,7 +631,6 @@ Napi::Value ASK::ImageFaceCompareUrl(const Napi::CallbackInfo& info) {
633
631
  return obj;
634
632
  }
635
633
 
636
-
637
634
  ////获取激活信息(采集离线激活信息、激活文件信息、SDK版本信息)
638
635
  void ASK::getSdkRelatedInfo() {
639
636
  printf("\n************* ArcFace SDK Info *****************\n");
@@ -716,14 +713,12 @@ int ASK::ColorSpaceConversion(MInt32 width, MInt32 height, MInt32 format, MUInt8
716
713
  return 1;
717
714
  }
718
715
 
719
-
720
-
721
716
  MUInt8* ASK::processFile(const char* filePath, int& picWidth, int& picHeight) {
722
717
  cv::Mat src = imread(filePath);
723
718
  cout<<filePath<<endl;
724
719
  int Width = src.cols;
725
720
  int Height = src.rows;
726
- cout << "Width:" << Width << ",Height:"<<Height<<endl;
721
+ cout << "Width:" << Width << ",Height:"<<Height << " flags: "<< src.flags << " dims: " << src.dims <<endl;
727
722
  int wScore = Width % 4;
728
723
  int hScore = Height % 2;
729
724
  cv::Mat dest;
@@ -777,29 +772,65 @@ cv::Mat curlImg(const char *img_url, int timeout=100000)
777
772
  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); //重定向一次
778
773
  CURLcode res = curl_easy_perform(curl); // start curl
779
774
  curl_easy_cleanup(curl); // cleanup
780
- cout<<res<<"xxxx" << stream.size() << " " << stream.max_size()<<endl;
775
+ cout<<res<<" xxxx " << stream.size() << " " << stream.max_size()<<endl;
781
776
  return imdecode(stream, -1); // 'keep-as-is'
782
777
  }
783
778
 
779
+ void modifyImageFormat(cv::Mat& out, cv::Mat& in, int channel)
780
+ {
781
+ if (channel == 4) {
782
+ in.convertTo(out, CV_8UC4);
783
+ } else if (channel == 3) {
784
+ in.convertTo(out, CV_8UC3);
785
+ } else if (channel == 2) {
786
+ in.convertTo(out, CV_8UC2);
787
+ } else {
788
+ in.convertTo(out, CV_8U);
789
+ }
790
+ }
791
+
784
792
  MUInt8* ASK::processFileUrl(const char* url, int& picWidth, int& picHeight) {
785
793
  cv::Mat src = curlImg(url);
786
794
  int Width = src.cols;
787
795
  int Height = src.rows;
788
- cout << "Width:" << Width << ",Height:"<<Height<<endl;
796
+ int depth = src.depth();
797
+ int channel = src.channels();
798
+ cout << "Width:" << Width << ",Height:"<<Height <<endl;
799
+ cout << "dims: " << src.dims << endl;
800
+ cout << "channels: " << channel << endl;
801
+ cout << "depth: " << depth << endl;
802
+
789
803
  int wScore = Width % 4;
790
804
  int hScore = Height % 2;
791
805
  cv::Mat dest;
792
806
  if (wScore != 0 || hScore != 0) {
807
+ cout << "processFileUrl ou:" <<endl;
793
808
  Width -= wScore;
794
809
  Height -= hScore;
795
810
  cv::Mat dst;
796
811
  cv::resize(src, dst, cv::Size(Width, Height));
797
- src.release();
798
- cvtColor(dst, dest, COLOR_BGR2YUV_I420);
812
+ if (depth != 0) { //bit数仅支持8
813
+ cv::Mat mid;
814
+ modifyImageFormat(mid, dst, channel);
815
+ cvtColor(mid, dest, COLOR_BGR2YUV_I420);
816
+ mid.release();
817
+ } else {
818
+ cvtColor(dst, dest, COLOR_BGR2YUV_I420);
819
+ }
820
+
799
821
  dst.release();
800
822
  } else {
801
- cvtColor(src, dest, COLOR_BGR2YUV_I420);
823
+ cout << "processFileUrl ji:" <<endl;
824
+ if (depth != 0) { //bit数仅支持8
825
+ cv::Mat mid;
826
+ modifyImageFormat(mid, src, channel);
827
+ cvtColor(mid, dest, COLOR_BGR2YUV_I420);
828
+ mid.release();
829
+ } else {
830
+ cvtColor(src, dest, COLOR_BGR2YUV_I420);
831
+ }
802
832
  }
833
+
803
834
  int len = Height*Width*3/2;
804
835
  MUInt8* imageData = (MUInt8*)malloc(len);
805
836
  memset(imageData, 0, len);
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hzt_asc",
3
- "version": "1.0.8",
3
+ "version": "1.1.0",
4
4
  "main": "index.js",
5
5
  "description": "hzt_asc_v3.",
6
6
  "author": {