hzt_asc 1.1.1 → 1.1.3

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.
Files changed (2) hide show
  1. package/ask.cc +26 -50
  2. package/package.json +1 -1
package/ask.cc CHANGED
@@ -149,19 +149,22 @@ Napi::Value ASK::faceDetectUrl(const Napi::CallbackInfo& info) {
149
149
  Napi::TypeError::New(env, "input expected").ThrowAsJavaScriptException();
150
150
  return errorData(env, "input expected"); //Napi::Number::New(info.Env(), -1);
151
151
  }
152
+ Napi::Object obj = Napi::Object::New(env);
152
153
  string filePath = info[0].As<Napi::String>().ToString();
153
154
  int Width, Height;
154
155
  MUInt8* imageData = processFileUrl(filePath.c_str(), Width, Height);
155
156
  if (!imageData) {
156
- Napi::TypeError::New(env, "image download error").ThrowAsJavaScriptException();
157
- return errorData(env, "image download error"); //Napi::Number::New(info.Env(), -1);
157
+ // Napi::TypeError::New(env, "image download error").ThrowAsJavaScriptException();
158
+ // return errorData(env, "image download error");
159
+ obj.Set(Napi::String::New(env, "faceNum"), 0);
160
+ return obj;
158
161
  }
159
162
  ASVLOFFSCREEN offscreen = { 0 };
160
163
  ColorSpaceConversion(Width, Height, ASVL_PAF_NV21, imageData, offscreen);
161
164
  ASF_MultiFaceInfo detectedFaces = { 0 };
162
165
  MRESULT res = ASFDetectFacesEx(this->handle, &offscreen, &detectedFaces);
163
166
 
164
- Napi::Object obj = Napi::Object::New(env);
167
+
165
168
  obj.Set(Napi::String::New(env, "faceNum"), detectedFaces.faceNum);
166
169
  Napi::Array list = Napi::Array::New(env, detectedFaces.faceNum);
167
170
  for(int i = 0; i < detectedFaces.faceNum; ++i) {
@@ -245,12 +248,14 @@ Napi::Value ASK::faceFeatureExtractUrl(const Napi::CallbackInfo& info) {
245
248
  return errorData(env, "input expected"); //Napi::Number::New(info.Env(), -1);
246
249
  }
247
250
  string filePath = info[0].As<Napi::String>().ToString();
248
-
251
+ Napi::Object obj = Napi::Object::New(env);
249
252
  int Width, Height;
250
253
  MUInt8* imageData = processFileUrl(filePath.c_str(), Width, Height);
251
254
  if (!imageData) {
252
- Napi::TypeError::New(env, "image download error").ThrowAsJavaScriptException();
253
- return errorData(env, "image download error"); //Napi::Number::New(info.Env(), -1);
255
+ // Napi::TypeError::New(env, "image download error").ThrowAsJavaScriptException();
256
+ // return errorData(env, "image download error"); //Napi::Number::New(info.Env(), -1);
257
+ obj.Set(Napi::String::New(env, "faceNum"), 0);
258
+ return obj;
254
259
  }
255
260
  ASVLOFFSCREEN offscreen = { 0 };
256
261
  ColorSpaceConversion(Width, Height, ASVL_PAF_NV21, imageData, offscreen);
@@ -258,7 +263,7 @@ Napi::Value ASK::faceFeatureExtractUrl(const Napi::CallbackInfo& info) {
258
263
  ASF_MultiFaceInfo detectedFaces = { 0 };
259
264
  MRESULT res = ASFDetectFacesEx(this->handle, &offscreen, &detectedFaces);
260
265
 
261
- Napi::Object obj = Napi::Object::New(env);
266
+
262
267
  obj.Set(Napi::String::New(env, "faceNum"), detectedFaces.faceNum);
263
268
  if (0 == detectedFaces.faceNum) {
264
269
  SafeFree(imageData);
@@ -567,19 +572,22 @@ Napi::Value ASK::ImageFaceCompareUrl2(const Napi::CallbackInfo& info) {
567
572
  Napi::TypeError::New(env, "input expected").ThrowAsJavaScriptException();
568
573
  return errorData(env, "input expected");
569
574
  }
575
+ Napi::Object obj = Napi::Object::New(env);
570
576
  string filePath = info[0].As<Napi::String>().ToString();
571
577
  int Width, Height;
572
578
  MUInt8* imageData = processFileUrl(filePath.c_str(), Width, Height);
573
579
  if (!imageData) {
574
- Napi::TypeError::New(env, "image download error").ThrowAsJavaScriptException();
575
- return errorData(env, "image download error"); //Napi::Number::New(info.Env(), -1);
580
+ // Napi::TypeError::New(env, "image download error").ThrowAsJavaScriptException();
581
+ // return errorData(env, "image download error"); //Napi::Number::New(info.Env(), -1);
582
+ obj.Set(Napi::String::New(env, "faceNum"), 0);
583
+ return obj;
576
584
  }
577
585
  ASVLOFFSCREEN offscreen = { 0 };
578
586
  ColorSpaceConversion(Width, Height, ASVL_PAF_NV21, imageData, offscreen);
579
587
 
580
588
  ASF_MultiFaceInfo detectedFaces = { 0 };
581
589
  MRESULT res = ASFDetectFacesEx(this->handle, &offscreen, &detectedFaces);
582
- Napi::Object obj = Napi::Object::New(env);
590
+
583
591
  obj.Set(Napi::String::New(env, "faceNum"), detectedFaces.faceNum);
584
592
  if (0 == detectedFaces.faceNum) {
585
593
  SafeFree(imageData);
@@ -598,19 +606,22 @@ Napi::Value ASK::ImageFaceCompareUrl(const Napi::CallbackInfo& info) {
598
606
  Napi::TypeError::New(env, "input expected").ThrowAsJavaScriptException();
599
607
  return errorData(env, "input expected");
600
608
  }
609
+ Napi::Object obj = Napi::Object::New(env);
601
610
  string filePath = info[0].As<Napi::String>().ToString();
602
611
  int Width, Height;
603
612
  MUInt8* imageData = processFileUrl(filePath.c_str(), Width, Height);
604
613
  if (!imageData) {
605
- Napi::TypeError::New(env, "image download error").ThrowAsJavaScriptException();
606
- return errorData(env, "image download error"); //Napi::Number::New(info.Env(), -1);
614
+ // Napi::TypeError::New(env, "image download error").ThrowAsJavaScriptException();
615
+ // return errorData(env, "image download error"); //Napi::Number::New(info.Env(), -1);
616
+ obj.Set(Napi::String::New(env, "faceNum"), 0);
617
+ return obj;
607
618
  }
608
619
  ASVLOFFSCREEN offscreen = { 0 };
609
620
  ColorSpaceConversion(Width, Height, ASVL_PAF_NV21, imageData, offscreen);
610
621
 
611
622
  ASF_MultiFaceInfo detectedFaces = { 0 };
612
623
  MRESULT res = ASFDetectFacesEx(this->handle, &offscreen, &detectedFaces);
613
- Napi::Object obj = Napi::Object::New(env);
624
+
614
625
  obj.Set(Napi::String::New(env, "faceNum"), detectedFaces.faceNum);
615
626
  if (0 == detectedFaces.faceNum) {
616
627
  SafeFree(imageData);
@@ -790,11 +801,11 @@ cv::Mat curlImg(const char *img_url, int timeout=100000)
790
801
 
791
802
  curl_easy_cleanup(curl); // cleanup
792
803
  if (res != CURLE_OK) {
793
- cout << "curl errcode=" << res << img_url <<endl;
804
+ cout << "curl errcode=" << res << " " << img_url <<endl;
794
805
  cv::Mat dest(0, 0, 1);
795
806
  return dest;
796
807
  }
797
- cout<<res<<" xxxx " << stream.size() << img_url << stream.max_size()<<endl;
808
+ cout<<img_url<<" download: " << stream.size() << " " << stream.max_size()<<endl;
798
809
  return imdecode(stream, -1); // 'keep-as-is'
799
810
  }
800
811
 
@@ -831,7 +842,6 @@ MUInt8* ASK::processFileUrl(const char* url, int& picWidth, int& picHeight) {
831
842
  int hScore = Height % 2;
832
843
  cv::Mat dest;
833
844
  if (wScore != 0 || hScore != 0) {
834
- //cout << "processFileUrl ou:" <<endl;
835
845
  Width -= wScore;
836
846
  Height -= hScore;
837
847
  cv::Mat dst;
@@ -847,7 +857,6 @@ MUInt8* ASK::processFileUrl(const char* url, int& picWidth, int& picHeight) {
847
857
 
848
858
  dst.release();
849
859
  } else {
850
- //cout << "processFileUrl ji:" <<endl;
851
860
  if (depth != 0) { //bit数仅支持8
852
861
  cv::Mat mid;
853
862
  modifyImageFormat(mid, src, channel);
@@ -909,39 +918,6 @@ MUInt8* ASK::processFileUrl(const char* url, int& picWidth, int& picHeight) {
909
918
  // ColorSpaceConversion(Width, Height, ASVL_PAF_NV21, imageData, offscreen);
910
919
  // }
911
920
 
912
- // void ASK::processFileUrl(const char* url, MUInt8* imageData, ASVLOFFSCREEN& offscreen) {
913
- // cv::Mat src = curlImg(url);
914
- // int Width = src.cols;
915
- // int Height = src.rows;
916
- // cout << "Width:" << Width << ",Height:"<<Height<<endl;
917
- // int wScore = Width % 4;
918
- // int hScore = Height % 2;
919
- // cv::Mat dest;
920
- // if (wScore != 0 || hScore != 0) {
921
- // Width -= wScore;
922
- // Height -= hScore;
923
- // cv::Mat dst;
924
- // cv::resize(src, dst, cv::Size(Width, Height));
925
- // src.release();
926
- // //src = dst;
927
- // cvtColor(dst, dest, COLOR_BGR2YUV_I420);
928
- // dst.release();
929
- // } else {
930
- // cvtColor(src, dest, COLOR_BGR2YUV_I420);
931
- // }
932
-
933
- // int len = Height*Width*3/2;
934
- // imageData = (MUInt8*)malloc(len);
935
- // memset(imageData, 0, len);
936
- // memcpy(imageData, dest.data, len);
937
- // src.release();
938
- // dest.release();
939
- // ColorSpaceConversion(Width, Height, ASVL_PAF_NV21, imageData, offscreen);
940
- // }
941
-
942
-
943
-
944
-
945
921
 
946
922
 
947
923
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hzt_asc",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "main": "index.js",
5
5
  "description": "hzt_asc_v3.",
6
6
  "author": {