hzt_asc 1.0.7 → 1.0.9

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
@@ -92,7 +92,7 @@ ASK::ASK(const Napi::CallbackInfo& info) : Napi::ObjectWrap<ASK>(info) {
92
92
 
93
93
  ASK::~ASK()
94
94
  {
95
- delete []mFeatureInfoList;
95
+ // delete []mFeatureInfoList;
96
96
  ASFUninitEngine(this->handle);
97
97
  printf("ASK end\n");
98
98
  }
@@ -142,7 +142,6 @@ Napi::Value ASK::faceDetect(const Napi::CallbackInfo& info) {
142
142
  return obj;
143
143
  }
144
144
 
145
-
146
145
  Napi::Value ASK::faceDetectUrl(const Napi::CallbackInfo& info) {
147
146
  Napi::Env env = info.Env();
148
147
  int length = info.Length();
@@ -176,8 +175,6 @@ Napi::Value ASK::faceDetectUrl(const Napi::CallbackInfo& info) {
176
175
  return obj;
177
176
  }
178
177
 
179
-
180
-
181
178
  Napi::Value ASK::faceFeatureExtract(const Napi::CallbackInfo& info) {
182
179
  Napi::Env env = info.Env();
183
180
  int length = info.Length();
@@ -284,7 +281,6 @@ Napi::Value ASK::faceFeatureExtractUrl(const Napi::CallbackInfo& info) {
284
281
  return obj;
285
282
  }
286
283
 
287
-
288
284
  Napi::Value ASK::faceFeatureInfo(const Napi::CallbackInfo& info) {
289
285
  Napi::Env env = info.Env();
290
286
  int length = info.Length();
@@ -335,7 +331,6 @@ void strToFeatureInfo(string& feature, ASF_FaceFeature& featureInfo) {
335
331
  featureInfo.feature = reinterpret_cast<MByte*>(feature11);
336
332
  }
337
333
 
338
-
339
334
  Napi::Value ASK::faceFeatureCompare(const Napi::CallbackInfo& info) {
340
335
  Napi::Env env = info.Env();
341
336
  //printf("AcceptArrayBuffer from js %d \n", info.Length());
@@ -368,10 +363,10 @@ Napi::Value ASK::faceFeatureCompare(const Napi::CallbackInfo& info) {
368
363
 
369
364
  }
370
365
 
371
-
372
- bool compareScore(MFaceSore& a, MFaceSore& b){
373
- if (b.score > a.score) return false;
374
- return true;
366
+ bool compareScore(const MFaceSore& a, const MFaceSore& b){
367
+ // if (b.score > a.score) return false;
368
+ // return true;
369
+ return a.score > b.score;//
375
370
  }
376
371
 
377
372
  Napi::Value ASK::ImageFaceCompare(const Napi::CallbackInfo& info) {
@@ -422,7 +417,7 @@ Napi::Value ASK::ImageFaceCompare(const Napi::CallbackInfo& info) {
422
417
 
423
418
  ASF_FaceFeatureInfo* info = new ASF_FaceFeatureInfo();
424
419
  info->searchId = searchId;
425
- info->tag = (*tag).c_str();
420
+ info->tag = *tag; //(*tag).c_str();
426
421
  info->feature = featureInfo;
427
422
  featureInfoList[i] = *info;
428
423
  }
@@ -483,27 +478,80 @@ Napi::Value ASK::RegisterFaces(const Napi::CallbackInfo& info) {
483
478
  return errorData(env, "array expected");
484
479
  }
485
480
  Napi::Array arr = info[0].As<Napi::Array>();
481
+ m_vecFeatureInfoList.clear();
482
+
486
483
  MUInt32 len = arr.Length();
487
- ASF_FaceFeatureInfo* featureInfoList = new ASF_FaceFeatureInfo[len];
484
+ //ASF_FaceFeatureInfo* featureInfoList = new ASF_FaceFeatureInfo[len];
488
485
  for(int i = 0; i < len; ++i) {
489
486
  Napi::Object obj = static_cast<Napi::Value>(arr[i]).As<Napi::Object>().ToObject();
490
487
  MInt32 searchId = obj.Get(static_cast<napi_value>(Napi::String::New(info.Env(),"searchId"))).As<Napi::Number>().Uint32Value();
491
- std::string* tag = new std::string();
492
- *tag = obj.Get(static_cast<napi_value>(Napi::String::New(info.Env(),"tag"))).As<Napi::String>().ToString();
493
- //Napi::ArrayBuffer buf = obj.Get(static_cast<napi_value>(Napi::String::New(info.Env(),"feature"))).As<Napi::ArrayBuffer>();
488
+ // std::string* tag = new std::string();
489
+ // *tag = obj.Get(static_cast<napi_value>(Napi::String::New(info.Env(),"tag"))).As<Napi::String>().ToString();
490
+ // //Napi::ArrayBuffer buf = obj.Get(static_cast<napi_value>(Napi::String::New(info.Env(),"feature"))).As<Napi::ArrayBuffer>();
494
491
  ASF_FaceFeature* featureInfo = new ASF_FaceFeature();
495
- std::string* feature = new std::string();
496
- *feature = obj.Get(static_cast<napi_value>(Napi::String::New(info.Env(),"feature"))).As<Napi::String>().ToString();
497
- strToFeatureInfo(*feature, *featureInfo);
498
- featureInfoList[i].searchId = searchId;
499
- featureInfoList[i].tag = (*tag).c_str();
500
- featureInfoList[i].feature = featureInfo;
501
- }
502
- mFeatureInfoList = featureInfoList;
503
- mFeatureLen = len;
492
+ // std::string* feature = new std::string();
493
+ // *feature = obj.Get(static_cast<napi_value>(Napi::String::New(info.Env(),"feature"))).As<Napi::String>().ToString();
494
+ std::string strFeature = obj.Get(static_cast<napi_value>(Napi::String::New(info.Env(),"feature"))).As<Napi::String>().ToString();
495
+ strToFeatureInfo(strFeature, *featureInfo);
496
+ // featureInfoList[i].searchId = searchId;
497
+ // featureInfoList[i].tag = *tag; //(*tag).c_str();
498
+ // featureInfoList[i].feature = featureInfo;
499
+ ASF_FaceFeatureInfo fInfo = {0};
500
+ fInfo.searchId = searchId;
501
+ fInfo.tag = obj.Get(static_cast<napi_value>(Napi::String::New(env,"tag"))).As<Napi::String>().ToString();
502
+ fInfo.feature = featureInfo;
503
+ m_vecFeatureInfoList.push_back(fInfo);
504
+ }
505
+ // mFeatureInfoList = featureInfoList;
506
+ // mFeatureLen = len;
504
507
  return Napi::Number::New(env, 1);
505
508
  }
506
509
 
510
+ Napi::Array ASK::faceReg(std::vector<ASF_FaceFeatureInfo>& vecFeatureInfoList, ASF_MultiFaceInfo& detectedFaces, Napi::Env& env, ASVLOFFSCREEN& offscreen) {
511
+ Napi::Array list = Napi::Array::New(env, detectedFaces.faceNum);
512
+ for(int i = 0; i < detectedFaces.faceNum; ++i) {
513
+ ASF_SingleFaceInfo sData;
514
+ getDetectFaceInfo(detectedFaces, sData, i);
515
+ ASF_FaceFeature feature = { 0 };
516
+ MRESULT res = ASFFaceFeatureExtractEx(handle, &offscreen, &sData, &feature);
517
+ vector<MFaceSore> vecfaceScores;
518
+ for(int j = 0; j < vecFeatureInfoList.size(); ++j) {
519
+ ASF_FaceFeatureInfo& fInfo = vecFeatureInfoList[j];
520
+ MFloat confidenceLevel;
521
+ MRESULT res1 = ASFFaceFeatureCompare(this->handle, &feature, fInfo.feature, &confidenceLevel);
522
+ //cout << " confidenceLevel: " << confidenceLevel;
523
+ MFaceSore sInfo;
524
+ sInfo.searchId = fInfo.searchId;
525
+ sInfo.score = confidenceLevel;
526
+ sInfo.name = fInfo.tag;
527
+ vecfaceScores.push_back(sInfo);
528
+ }
529
+ sort(vecfaceScores.begin(), vecfaceScores.end(), compareScore);
530
+ int ll = vecfaceScores.size() > 3? 3 : vecfaceScores.size();
531
+ Napi::Array mFaceScores = Napi::Array::New(env, ll);
532
+ //cout << " i=" << i << ", len=" << ll << ",mFeatureLen=" << vecFeatureInfoList.size() << endl;
533
+ for(int n = 0; n < ll; ++n) {
534
+ MFaceSore& sInfo = vecfaceScores[n];
535
+ Napi::Object faceScore = Napi::Object::New(env);
536
+ faceScore.Set(Napi::String::New(env, "searchId"), sInfo.searchId);
537
+ faceScore.Set(Napi::String::New(env, "score"), sInfo.score);
538
+ faceScore.Set(Napi::String::New(env, "name"), sInfo.name);
539
+ //cout << "name:" << sInfo.name << ",searchId:" << sInfo.searchId << ",score=" << sInfo.score << endl;
540
+ mFaceScores[n] = faceScore;
541
+ }
542
+ Napi::Object data = Napi::Object::New(env);
543
+ data.Set(Napi::String::New(env, "left"), sData.faceRect.left);
544
+ data.Set(Napi::String::New(env, "top"), sData.faceRect.top);
545
+ data.Set(Napi::String::New(env, "right"), sData.faceRect.right);
546
+ data.Set(Napi::String::New(env, "bottom"), sData.faceRect.bottom);
547
+ data.Set(Napi::String::New(env, "faceScores"), mFaceScores);
548
+ list[i] = data;
549
+ vecfaceScores.clear();
550
+ }
551
+ //obj.Set(Napi::String::New(env, "faceRects"), list);
552
+ return list;
553
+ }
554
+
507
555
  Napi::Value ASK::ImageFaceCompareUrl2(const Napi::CallbackInfo& info) {
508
556
  Napi::Env env = info.Env();
509
557
  int length = info.Length();
@@ -519,53 +567,18 @@ Napi::Value ASK::ImageFaceCompareUrl2(const Napi::CallbackInfo& info) {
519
567
 
520
568
  ASF_MultiFaceInfo detectedFaces = { 0 };
521
569
  MRESULT res = ASFDetectFacesEx(this->handle, &offscreen, &detectedFaces);
522
- //return Napi::Number::New(env, 1);
523
570
  Napi::Object obj = Napi::Object::New(env);
524
571
  obj.Set(Napi::String::New(env, "faceNum"), detectedFaces.faceNum);
525
572
  if (0 == detectedFaces.faceNum) {
526
573
  SafeFree(imageData);
527
574
  return obj;
528
575
  }
529
- //compare
530
- Napi::Array list = Napi::Array::New(env, detectedFaces.faceNum);
531
- for(int i = 0; i < detectedFaces.faceNum; ++i) {
532
- ASF_SingleFaceInfo sData;
533
- getDetectFaceInfo(detectedFaces, sData, i);
534
- ASF_FaceFeature feature = { 0 };
535
- res = ASFFaceFeatureExtractEx(handle, &offscreen, &sData, &feature);
536
- MFaceSore* faceScores = new MFaceSore[mFeatureLen];
537
- for(int j = 0; j < mFeatureLen; ++j) {
538
- MFloat confidenceLevel;
539
- MRESULT res1 = ASFFaceFeatureCompare(this->handle, &feature, mFeatureInfoList[j].feature, &confidenceLevel);
540
- faceScores[j].searchId = mFeatureInfoList[j].searchId;
541
- faceScores[j].score = confidenceLevel;
542
- faceScores[j].name = mFeatureInfoList[j].tag;
543
- }
544
- sort(faceScores, faceScores + mFeatureLen, compareScore);
545
- int ll = mFeatureLen > 5? 5 : mFeatureLen;
546
- Napi::Array mFaceScores = Napi::Array::New(env, ll);
547
- for(int n = 0; n < ll; ++n) {
548
- Napi::Object faceScore = Napi::Object::New(env);
549
- faceScore.Set(Napi::String::New(env, "searchId"), faceScores[n].searchId);
550
- faceScore.Set(Napi::String::New(env, "score"), faceScores[n].score);
551
- faceScore.Set(Napi::String::New(env, "name"), faceScores[n].name);
552
- mFaceScores[n] = faceScore;
553
- }
554
- Napi::Object data = Napi::Object::New(env);
555
- data.Set(Napi::String::New(env, "left"), sData.faceRect.left);
556
- data.Set(Napi::String::New(env, "top"), sData.faceRect.top);
557
- data.Set(Napi::String::New(env, "right"), sData.faceRect.right);
558
- data.Set(Napi::String::New(env, "bottom"), sData.faceRect.bottom);
559
- data.Set(Napi::String::New(env, "faceScores"), mFaceScores);
560
- list[i] = data;
561
- delete []faceScores;
562
- }
576
+ Napi::Array list = faceReg(this->m_vecFeatureInfoList, detectedFaces, env, offscreen);
563
577
  obj.Set(Napi::String::New(env, "faceRects"), list);
564
578
  SafeFree(imageData);
565
579
  return obj;
566
580
  }
567
581
 
568
-
569
582
  Napi::Value ASK::ImageFaceCompareUrl(const Napi::CallbackInfo& info) {
570
583
  Napi::Env env = info.Env();
571
584
  int length = info.Length();
@@ -584,7 +597,7 @@ Napi::Value ASK::ImageFaceCompareUrl(const Napi::CallbackInfo& info) {
584
597
  Napi::Object obj = Napi::Object::New(env);
585
598
  obj.Set(Napi::String::New(env, "faceNum"), detectedFaces.faceNum);
586
599
  if (0 == detectedFaces.faceNum) {
587
- SafeArrayDelete(imageData);
600
+ SafeFree(imageData);
588
601
  return obj;
589
602
  }
590
603
 
@@ -595,73 +608,29 @@ Napi::Value ASK::ImageFaceCompareUrl(const Napi::CallbackInfo& info) {
595
608
  }
596
609
  Napi::Array arr = info[1].As<Napi::Array>();
597
610
  MUInt32 len = arr.Length();
598
- ASF_FaceFeatureInfo* featureInfoList = new ASF_FaceFeatureInfo[len];
611
+
612
+ std::vector<ASF_FaceFeatureInfo> vecFeatureInfoList;
599
613
  for(int i = 0; i < len; ++i) {
600
614
  Napi::Object obj = static_cast<Napi::Value>(arr[i]).As<Napi::Object>().ToObject();
601
615
  MInt32 searchId = obj.Get(static_cast<napi_value>(Napi::String::New(info.Env(),"searchId"))).As<Napi::Number>().Uint32Value();
602
- std::string* tag = new std::string();
603
- *tag = obj.Get(static_cast<napi_value>(Napi::String::New(info.Env(),"tag"))).As<Napi::String>().ToString();
604
- //Napi::ArrayBuffer buf = obj.Get(static_cast<napi_value>(Napi::String::New(info.Env(),"feature"))).As<Napi::ArrayBuffer>();
616
+ std::string strFeature = obj.Get(static_cast<napi_value>(Napi::String::New(info.Env(),"feature"))).As<Napi::String>().ToString();
605
617
  ASF_FaceFeature* featureInfo = new ASF_FaceFeature();
606
- std::string* feature = new std::string();
607
- *feature = obj.Get(static_cast<napi_value>(Napi::String::New(info.Env(),"feature"))).As<Napi::String>().ToString();
608
- strToFeatureInfo(*feature, *featureInfo);
609
- // featureInfo->featureSize = buf.ByteLength();
610
- // featureInfo->feature = reinterpret_cast<MByte*>(buf.Data());;
611
- //ASF_FaceFeatureInfo* info = new ASF_FaceFeatureInfo();
612
- featureInfoList[i].searchId = searchId;
613
- featureInfoList[i].tag = (*tag).c_str();
614
- featureInfoList[i].feature = featureInfo;
615
- //featureInfoList[i] = *info;
616
- }
617
-
618
- //compare
619
- Napi::Array list = Napi::Array::New(env, detectedFaces.faceNum);
620
- for(int i = 0; i < detectedFaces.faceNum; ++i) {
621
- ASF_SingleFaceInfo sData;
622
- getDetectFaceInfo(detectedFaces, sData, i);
623
- ASF_FaceFeature feature = { 0 };
624
- res = ASFFaceFeatureExtractEx(handle, &offscreen, &sData, &feature);
625
- MFaceSore* faceScores = new MFaceSore[len];
626
- for(int j = 0; j < len; ++j) {
627
- MFloat confidenceLevel;
628
- MRESULT res1 = ASFFaceFeatureCompare(this->handle, &feature, featureInfoList[j].feature, &confidenceLevel);
629
- //cout << confidenceLevel <<endl;
630
- //MFaceSore* pFace = new MFaceSore();
631
- faceScores[j].searchId = featureInfoList[j].searchId;
632
- faceScores[j].score = confidenceLevel;
633
- faceScores[j].name = featureInfoList[j].tag;
634
- // faceScores[j] = *pFace;
635
- }
636
- sort(faceScores, faceScores + len, compareScore);
637
- int ll = len > 5? 5 : len;
638
- Napi::Array mFaceScores = Napi::Array::New(env, ll);
639
- for(int n = 0; n < ll; ++n) {
640
- Napi::Object faceScore = Napi::Object::New(env);
641
- faceScore.Set(Napi::String::New(env, "searchId"), faceScores[n].searchId);
642
- faceScore.Set(Napi::String::New(env, "score"), faceScores[n].score);
643
- faceScore.Set(Napi::String::New(env, "name"), faceScores[n].name);
644
- mFaceScores[n] = faceScore;
645
- }
646
- Napi::Object data = Napi::Object::New(env);
647
- data.Set(Napi::String::New(env, "left"), sData.faceRect.left);
648
- data.Set(Napi::String::New(env, "top"), sData.faceRect.top);
649
- data.Set(Napi::String::New(env, "right"), sData.faceRect.right);
650
- data.Set(Napi::String::New(env, "bottom"), sData.faceRect.bottom);
651
- data.Set(Napi::String::New(env, "faceScores"), mFaceScores);
652
- list[i] = data;
653
- delete []faceScores;
654
- }
618
+ strToFeatureInfo(strFeature, *featureInfo);
619
+ ASF_FaceFeatureInfo fInfo = {0};
620
+ fInfo.searchId = searchId;
621
+ fInfo.tag = obj.Get(static_cast<napi_value>(Napi::String::New(env,"tag"))).As<Napi::String>().ToString();
622
+ fInfo.feature = featureInfo;
623
+ vecFeatureInfoList.push_back(fInfo);
624
+ }
625
+ Napi::Array list = faceReg(vecFeatureInfoList, detectedFaces, env, offscreen);
655
626
  obj.Set(Napi::String::New(env, "faceRects"), list);
656
627
  SafeFree(imageData);
657
628
  for(int i = 0; i < len; ++i) {
658
- delete featureInfoList[i].feature;
629
+ delete vecFeatureInfoList[i].feature;
659
630
  }
660
- delete []featureInfoList;
661
631
  return obj;
662
632
  }
663
633
 
664
-
665
634
  ////获取激活信息(采集离线激活信息、激活文件信息、SDK版本信息)
666
635
  void ASK::getSdkRelatedInfo() {
667
636
  printf("\n************* ArcFace SDK Info *****************\n");
@@ -744,8 +713,6 @@ int ASK::ColorSpaceConversion(MInt32 width, MInt32 height, MInt32 format, MUInt8
744
713
  return 1;
745
714
  }
746
715
 
747
-
748
-
749
716
  MUInt8* ASK::processFile(const char* filePath, int& picWidth, int& picHeight) {
750
717
  cv::Mat src = imread(filePath);
751
718
  cout<<filePath<<endl;
@@ -805,7 +772,7 @@ cv::Mat curlImg(const char *img_url, int timeout=100000)
805
772
  curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1); //重定向一次
806
773
  CURLcode res = curl_easy_perform(curl); // start curl
807
774
  curl_easy_cleanup(curl); // cleanup
808
- cout<<res<<"xxxx" << stream.size() << " " << stream.max_size()<<endl;
775
+ cout<<res<<" xxxx " << stream.size() << " " << stream.max_size()<<endl;
809
776
  return imdecode(stream, -1); // 'keep-as-is'
810
777
  }
811
778
 
@@ -813,7 +780,8 @@ MUInt8* ASK::processFileUrl(const char* url, int& picWidth, int& picHeight) {
813
780
  cv::Mat src = curlImg(url);
814
781
  int Width = src.cols;
815
782
  int Height = src.rows;
816
- cout << "Width:" << Width << ",Height:"<<Height<<endl;
783
+ //const int Depth = src.depth;
784
+ cout << "Width:" << Width << ",Height:"<<Height << " " <<endl;
817
785
  int wScore = Width % 4;
818
786
  int hScore = Height % 2;
819
787
  cv::Mat dest;
@@ -823,11 +791,28 @@ MUInt8* ASK::processFileUrl(const char* url, int& picWidth, int& picHeight) {
823
791
  cv::Mat dst;
824
792
  cv::resize(src, dst, cv::Size(Width, Height));
825
793
  src.release();
826
- cvtColor(dst, dest, COLOR_BGR2YUV_I420);
794
+
795
+ cv::Mat mid;
796
+ dst.convertTo(mid, CV_8UC3);
797
+ cvtColor(mid, dest, COLOR_BGR2YUV_I420);
798
+ //cout << "processFileUrl3:" << mid.cols << ",mid.rows:"<<Height<<endl;
799
+ mid.release();
800
+
801
+ //cvtColor(dst, dest, COLOR_BGR2YUV_I420);
827
802
  dst.release();
828
803
  } else {
829
- cvtColor(src, dest, COLOR_BGR2YUV_I420);
830
- }
804
+ //cvtColor(src, dest, COLOR_BGR2YUV_I420);
805
+ cv::Mat mid;
806
+ src.convertTo(mid, CV_8UC3);
807
+ cvtColor(mid, dest, COLOR_BGR2YUV_I420);
808
+ //cout << "processFileUrl3:" << mid.cols << ",mid.rows:"<<Height<<endl;
809
+ mid.release();
810
+ }
811
+ // cv::Mat mid;
812
+ // src.convertTo(mid, CV_8UC3);
813
+ // cout << "processFileUrl2:" << Width << ",Height:"<<Height<<endl;
814
+ // cvtColor(mid, dest, COLOR_BGR2YUV_I420);
815
+ // cout << "processFileUrl3:" << mid.cols << ",mid.rows:"<<Height<<endl;
831
816
  int len = Height*Width*3/2;
832
817
  MUInt8* imageData = (MUInt8*)malloc(len);
833
818
  memset(imageData, 0, len);
package/ask.h CHANGED
@@ -7,6 +7,7 @@
7
7
  #include "asvloffscreen.h"
8
8
  #include "merror.h"
9
9
  #include <string>
10
+ #include <vector>
10
11
  typedef struct __face_score
11
12
  {
12
13
  MInt32 searchId;
@@ -17,7 +18,8 @@ typedef struct __face_score
17
18
  typedef struct{
18
19
  MInt32 searchId; // 唯一标识符
19
20
  LPASF_FaceFeature feature; // 人脸特征值
20
- MPCChar tag; // 备注
21
+ std::string tag;
22
+ //MPCChar tag; // 备注
21
23
  }ASF_FaceFeatureInfo, *LPASF_FaceFeatureInfo;
22
24
 
23
25
  class ASK : public Napi::ObjectWrap<ASK> {
@@ -35,7 +37,6 @@ class ASK : public Napi::ObjectWrap<ASK> {
35
37
  // Napi::Value RegisterFaceFeature(const Napi::CallbackInfo& info);
36
38
  // Napi::Value SearchFaceFeature(const Napi::CallbackInfo& info);
37
39
 
38
-
39
40
  Napi::Value ImageFaceCompare(const Napi::CallbackInfo& info);
40
41
 
41
42
  Napi::Value faceDetectUrl(const Napi::CallbackInfo& info);
@@ -52,13 +53,15 @@ class ASK : public Napi::ObjectWrap<ASK> {
52
53
  MUInt8* processFile(const char* filePath, int& picWidth, int& picHeight);
53
54
  //void processFileUrl(const char* filePath, MUInt8* imageData, ASVLOFFSCREEN& offscreen);
54
55
  MUInt8* processFileUrl(const char* url, int& picWidth, int& picHeight);
56
+ Napi::Array faceReg(std::vector<ASF_FaceFeatureInfo>& vecFeatureInfoList, ASF_MultiFaceInfo& detectedFaces, Napi::Env& env, ASVLOFFSCREEN& offscreen);
55
57
 
56
58
  // void mFaceDetect(ASVLOFFSCREEN& offscree, ASF_MultiFaceInfo* detectedFaces);
57
59
  // void mFaceFeatureExtract(ASVLOFFSCREEN& offscree, ASF_MultiFaceInfo* detectedFaces);
58
60
 
59
61
  MHandle handle;
60
- ASF_FaceFeatureInfo* mFeatureInfoList;
61
- MUInt32 mFeatureLen;
62
+ // ASF_FaceFeatureInfo* mFeatureInfoList;
63
+ // MUInt32 mFeatureLen;
64
+ std::vector<ASF_FaceFeatureInfo> m_vecFeatureInfoList;
62
65
  };
63
66
 
64
67
  #endif
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hzt_asc",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "main": "index.js",
5
5
  "description": "hzt_asc_v3.",
6
6
  "author": {