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.
- package/ask.cc +41 -23
- package/package.json +1 -1
- 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
|
-
|
|
784
|
-
|
|
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
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
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
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
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
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
|
|
23
|
-
|
|
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");
|