hzt_asc 1.0.9 → 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.
Files changed (3) hide show
  1. package/ask.cc +41 -23
  2. package/package.json +1 -1
  3. package/sample/demo.js +6 -2
package/ask.cc CHANGED
@@ -718,7 +718,7 @@ MUInt8* ASK::processFile(const char* filePath, int& picWidth, int& picHeight) {
718
718
  cout<<filePath<<endl;
719
719
  int Width = src.cols;
720
720
  int Height = src.rows;
721
- cout << "Width:" << Width << ",Height:"<<Height<<endl;
721
+ cout << "Width:" << Width << ",Height:"<<Height << " flags: "<< src.flags << " dims: " << src.dims <<endl;
722
722
  int wScore = Width % 4;
723
723
  int hScore = Height % 2;
724
724
  cv::Mat dest;
@@ -776,43 +776,61 @@ cv::Mat curlImg(const char *img_url, int timeout=100000)
776
776
  return imdecode(stream, -1); // 'keep-as-is'
777
777
  }
778
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
+
779
792
  MUInt8* ASK::processFileUrl(const char* url, int& picWidth, int& picHeight) {
780
793
  cv::Mat src = curlImg(url);
781
794
  int Width = src.cols;
782
795
  int Height = src.rows;
783
- //const int Depth = src.depth;
784
- 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
+
785
803
  int wScore = Width % 4;
786
804
  int hScore = Height % 2;
787
805
  cv::Mat dest;
788
806
  if (wScore != 0 || hScore != 0) {
807
+ cout << "processFileUrl ou:" <<endl;
789
808
  Width -= wScore;
790
809
  Height -= hScore;
791
810
  cv::Mat dst;
792
811
  cv::resize(src, dst, cv::Size(Width, Height));
793
- src.release();
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();
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
+ }
800
820
 
801
- //cvtColor(dst, dest, COLOR_BGR2YUV_I420);
802
821
  dst.release();
803
822
  } else {
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;
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
+ }
832
+ }
833
+
816
834
  int len = Height*Width*3/2;
817
835
  MUInt8* imageData = (MUInt8*)malloc(len);
818
836
  memset(imageData, 0, len);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hzt_asc",
3
- "version": "1.0.9",
3
+ "version": "1.1.0",
4
4
  "main": "index.js",
5
5
  "description": "hzt_asc_v3.",
6
6
  "author": {
package/sample/demo.js CHANGED
@@ -17,10 +17,14 @@ let start = Date.now();
17
17
  let ask = new addon.ASK(APPID, SDKKEY, ACTIVEKEY);
18
18
  //let ask2 = new addon.ASK(APPID, SDKKEY, ACTIVEKEY);
19
19
  printMem()
20
+ let xx2 = ask.FaceDetectUrl("http://image.haizitong.com/cc123be3667143e3af5c53a5906c6b42");
21
+ console.log("init end", xx2, Date.now() - start);
20
22
 
21
23
  let xx = ask.FaceDetectUrl("http://upload-file.haizitong.com/api/getFile/119c44a5-193f-4953-b59c-c1e55cd29f1a")
22
- let xx2 = ask.FaceDetectUrl("http://image.haizitong.com/cc123be3667143e3af5c53a5906c6b42");
23
- console.log("init end", xx, xx2, Date.now() - start);
24
+ //let xx = ask.FaceDetectUrl("https://min.haizitong.com/2/ali/i/fbad726e022742a78a2666580a9a0f0f139317")
25
+ //
26
+
27
+ console.log("init end", xx, Date.now() - start);
24
28
 
25
29
  // for(let i = 0; i < 10000; ++i) {
26
30
  // let num = ask.FaceFeatureExtractUrl("http://min.haizitong.com/2/ali/i/a5f91d52783d49989777e8b82b545e2c");