Skip to content

Commit

Permalink
update mobile face net param
Browse files Browse the repository at this point in the history
  • Loading branch information
kkroid committed Nov 14, 2020
1 parent 798e942 commit 6f5033e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 116 deletions.
18 changes: 7 additions & 11 deletions app/src/main/cpp/task/NCNNRecognizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,20 @@ class NCNNRecognizer {
}

float *getFeature(cv::Mat croppedFace) {
ncnn::Extractor ex = recognizer.create_extractor();
ex.set_num_threads(1);
ex.set_light_mode(true);
ncnn::Mat ncnnFace = ncnn::Mat::from_pixels(croppedFace.data,
ncnn::Mat ncnnFace = ncnn::Mat::from_pixels_resize(croppedFace.data,
ncnn::Mat::PIXEL_BGR2RGB,
croppedFace.cols,
croppedFace.rows);
croppedFace.rows,
112,
112);
ncnn::Extractor ex = recognizer.create_extractor();
// x.set_num_threads(4);
ex.input("data", ncnnFace);
ncnn::Mat out;
ex.extract("fc1", out);
float *feature = new float[128];
for (int j = 0; j < 128; j++) {
// TODO not working ?
if (std::isnan(out[j]) || std::isinf(out[j])) {
feature[j] = 0;
} else {
feature[j] = out[j];
}
feature[j] = out[j];
}
return feature;
}
Expand Down
95 changes: 0 additions & 95 deletions app/src/main/cpp/task/mobile_facenet.h

This file was deleted.

2 changes: 1 addition & 1 deletion app/src/main/java/com/kk/afdd/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ public class Config {
public static final int PREVIEW_WIDTH = 240;
public static final int PREVIEW_HEIGHT = 320;
public static final int ROTATION = 90;
public static final int FPS = 5;
public static final int FPS = 2;
public static final boolean MIRROR = true;
}
17 changes: 8 additions & 9 deletions app/src/main/java/com/kk/afdd/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,14 @@ public void onFaceDetected(String faceInfoJson) {
sFaceInfoType = new TypeToken<List<FaceInfo>>() {
}.getType();
}
String ff = faceInfoJson;
int maxLogSize = 1000;
for(int i = 0; i <= ff.length() / maxLogSize; i++) {
int start = i * maxLogSize;
int end = (i+1) * maxLogSize;
end = Math.min(end, ff.length());
Timber.v(ff.substring(start, end));
}
faceInfoJson = faceInfoJson.replaceAll("nan", "0").replaceAll("inf", "0");
// String ff = faceInfoJson;
// int maxLogSize = 1000;
// for(int i = 0; i <= ff.length() / maxLogSize; i++) {
// int start = i * maxLogSize;
// int end = (i+1) * maxLogSize;
// end = Math.min(end, ff.length());
// Timber.v(ff.substring(start, end));
// }
List<FaceInfo> faceInfoList = mGson.fromJson(faceInfoJson, sFaceInfoType);
if (faceInfoList.size() > 0) {
for (FaceInfo faceInfo : faceInfoList) {
Expand Down

0 comments on commit 6f5033e

Please sign in to comment.