Skip to content

Commit

Permalink
Merge pull request #133 from dpmaycry/master
Browse files Browse the repository at this point in the history
change rgb to bgr for android jni
  • Loading branch information
ShiqiYu authored Mar 28, 2019
2 parents 5d7fcbd + 52bc0b7 commit 6bfdf42
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions mobile/Android/app/src/main/cpp/facedetectcnn-jni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ Java_org_dp_facedetection_MainActivity_facedetect(JNIEnv *env,jobject /* this */
{
jobjectArray faceArgs = nullptr;
Mat& img = *(Mat*)matAddr;
Mat rgb = img.clone();
cvtColor(img, rgb, COLOR_RGBA2RGB);
Mat bgr = img.clone();
cvtColor(img, bgr, COLOR_RGBA2BGR);
__android_log_print(ANDROID_LOG_ERROR, JNITag,"convert RGBA to RGB");
//load an image and convert it to gray (single-channel)
if(rgb.empty())
if(bgr.empty())
{
fprintf(stderr, "Can not convert image");
return faceArgs;
Expand All @@ -43,7 +43,7 @@ Java_org_dp_facedetection_MainActivity_facedetect(JNIEnv *env,jobject /* this */
//////////////////////////////////////////
//!!! The input image must be a RGB one (three-channel)
//!!! DO NOT RELEASE pResults !!!
pResults = facedetect_cnn(pBuffer, (unsigned char*)(rgb.ptr(0)), rgb.cols, rgb.rows, (int)rgb.step);
pResults = facedetect_cnn(pBuffer, (unsigned char*)(bgr.ptr(0)), bgr.cols, bgr.rows, (int)bgr.step);
int numOfFaces = pResults ? *pResults : 0;
__android_log_print(ANDROID_LOG_ERROR, JNITag,"%d faces detected.\n", numOfFaces);

Expand Down
2 changes: 1 addition & 1 deletion mobile/Android/app/src/main/cpp/facedetectcnn.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ the use of this software, even if advised of the possibility of such damage.


int * facedetect_cnn(unsigned char * result_buffer, //buffer memory for storing face detection results, !!its size must be 0x20000 Bytes!!
unsigned char * rgb_image_data, int width, int height, int step); //input image, it must be RGB (three-channel) image!
unsigned char * rgb_image_data, int width, int height, int step); //input image, it must be BGR (three channels) insteed of RGB image!



Expand Down
Binary file modified mobile/Android/release/facedetection.apk
Binary file not shown.
Binary file modified mobile/Screenshot2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6bfdf42

Please sign in to comment.