请选择 进入手机版 | 继续访问电脑版
设为首页收藏本站

Android Studio 中文社区论坛

 找回密码
 立即注册
搜索
热搜: Android Sdk Gradle
查看: 1055|回复: 0

ndk-build error:commands commence before first target.

[复制链接]

1

主题

1

帖子

5

积分

新手上路

Rank: 1

积分
5
发表于 2016-11-20 09:23:09 | 显示全部楼层 |阅读模式
尝试好久都找不到原因 ,下面是完整的文件

Android.mk文件内容


LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
include $(BUILD_STATIC_LIBRARY)

## build opencv
TOP_LEVEL_PATH := $(abspath $(LOCAL_PATH)/..)
$(info TOP Level Path: $(TOP_LEVEL_PATH))
EXT_INSTALL_PATH = $(TOP_LEVEL_PATH)/third_party
OPENCV_PATH = $(EXT_INSTALL_PATH)/opencv/jni
OPENCV_IMCLUDE_DIR = $(OPENCV_PATH)/include
include $(CLEAR_VARS)
OPENCV_INSTALL_MODULES := on                               
OPENCV_CAMERA_MODULES := off
OPENCV_LIB_TYPE := STATIC
include $(OPENCV_PATH)/opencv.mk

LOCAL_MODULE := MyLibs
LOCAL_C_INCLUDES += \
                                $(OPENCV_INCLUDE_DIR)
LOCAL_SRC_FILES := android_luo_stone_facelandmarkdetection_NativeClass.cpp

LOCAL_LDLIBS += -lm -llog -latomic -ldl -lz -ljnigraphics
LOCAL_CPPFLAGS += -fexceptions -frtti -std=c++11

# import dlib
LOCAL_STATIC_LIBRARIES += dlib

include $(BUILD_SHARED_LIBRARY)



Application.mk

NDK_TOOLCHAIN_VERSION := clang
APP_STL := gnustl_static
APP_CPPFLAGS := -std=c++11 -frtti -fexceptions
APP_ABI := armeabi-v7a
APP_PLATFORM := android-8


C++文件


JNIEXPORT jstring JNICALL Java_android_luo_stone_facelandmarkdetection_NativeClass_getMessages
  (JNIEnv *env, jclass){
          env->NewStringUTF("JNI message");
  }

JNIEXPORT void JNICALL Java_android_luo_stone_facelandmarkdetection_NativeClass_LandmarkDetection
  (JNIEnv *env, jclass thiz, jlong addrInput, jlong addrOutput){
          Mat& image = *(Mat*)addrInput;
          Mat& dst = *(Mat*)addrOutput;

          faceDetectionDib(image, dst);
  }

  void faceDetectionDib(Mat& img, Mat& dst){
          try {
                  frontal_face_detector detector = get_frontal_face_detector();
                  shape_predictor pose_model;
                  deserialize("storage/emulated/0/shape_predictor_68_face_landmarks.dat")>>pose_model;

                  cv_image<bgr_pixel> cimg(img);

                  //detect use dlib
                  std::vector<dlib::rectangle> faces = detector(cimg);
                  //find pose
                  std::vector<full_object_detecton> shapes;

                  for(unsigned long i = 0;i < faces.size(); ++i)
                          shapes.push_back(pose_model(cimg, faces));

                  //render to mat
                  dst = img.clone();
                  renderToMat(shapes, dst);

          }catch(serialization_error& e){
                  cout<< endl << e.what() << endl;
          }
  }

  void renderToMat(std::vector<full_object_detecton>& dets, Mat& dst){

          Scalar color;
          int sz = 3;
          color = scalar(0,255,0);
//chin line
          for(unsigned long idx = 0; idx < dets.size(); idx++){

                  for (unsigned long i = 1; i <= 16; ++i)
                          cv::line(dst, Point(dets[idx].part(i).x(), dets[idx].part(i).y()), Point(dets[idx].part(i - 1).x(), dets[idx].part(i - 1).y()), color, sz);
          //line on top of nose
                  for (unsigned long i = 28; i <= 30; ++i)
                          cv::line(dst, Point(dets[idx].part(i).x(), dets[idx].part(i).y()), Point(dets[idx].part(i - 1).x(), dets[idx].part(i - 1).y()), color, sz);
          //left eyebrow
                  for (unsigned long i = 18; i <= 21; ++i)
                          cv::line(dst, Point(dets[idx].part(i).x(), dets[idx].part(i).y()), Point(dets[idx].part(i - 1).x(), dets[idx].part(i - 1).y()), color, sz);
          //right eyebrow
                  for (unsigned long i = 23; i <= 26; ++i)
                          cv::line(dst, Point(dets[idx].part(i).x(), dets[idx].part(i).y()), Point(dets[idx].part(i - 1).x(), dets[idx].part(i - 1).y()), color, sz);
    //bottom of nose
                  for (unsigned long i = 31; i <= 35; ++i)
                          cv::line(dst, Point(dets[idx].part(i).x(), dets[idx].part(i).y()), Point(dets[idx].part(i - 1).x(), dets[idx].part(i - 1).y()), color, sz);
                          cv::line(dst, Point(dets[idx].part(30).x(),dets[idx].part(30).y()), Point(dets[idx].part(35).x(), dets[idx].part(35).y()), color, sz);
          //left eye
                  for (unsigned long i = 37; i <= 41; ++i)
                          cv::line(dst, Point(dets[idx].part(i).x(), dets[idx].part(i).y()), Point(dets[idx].part(i - 1).x(), dets[idx].part(i - 1).y()), color, sz);
                          cv::line(dst, Point(dets[idx].part(36).x(),dets[idx].part(36).y()), Point(dets[idx].part(41).x(), dets[idx].part(41).y()), color, sz);
    //right eye
                  for (unsigned long i = 43; i <= 47; ++i)
                          cv::line(dst, Point(dets[idx].part(i).x(), dets[idx].part(i).y()), Point(dets[idx].part(i - 1).x(), dets[idx].part(i - 1).y()), color, sz);
                          cv::line(dst, Point(dets[idx].part(42).x(),dets[idx].part(42).y()), Point(dets[idx].part(47).x(), dets[idx].part(47).y()), color, sz);
          //lips out part
                  for (unsigned long i = 49; i <= 59; ++i)
                          cv::line(dst, Point(dets[idx].part(i).x(), dets[idx].part(i).y()), Point(dets[idx].part(i - 1).x(), dets[idx].part(i - 1).y()), color, sz);
                          cv::line(dst, Point(dets[idx].part(48).x(),dets[idx].part(48).y()), Point(dets[idx].part(59).x(), dets[idx].part(59).y()), color, sz);
          //lips inside part
                  for (unsigned long i = 61; i <= 67; ++i)
                          cv::line(dst, Point(dets[idx].part(i).x(), dets[idx].part(i).y()), Point(dets[idx].part(i - 1).x(), dets[idx].part(i - 1).y()), color, sz);
                          cv::line(dst, Point(dets[idx].part(60).x(),dets[idx].part(60).y()), Point(dets[idx].part(67).x(), dets[idx].part(67).y()), color, sz);
          }
  }

头文件

/* DO NOT EDIT THIS FILE - it is machine generated */
#include <iostream>
#include <jni.h>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>

#include <dlib/opencv.h>
#include <dlib/image_processing/frontal_face_detector.h>
#include <dlib/image_processing/render_face_detections.h>
#include <dlib/image_processing.h>
#include <dlib/gui_widgets.h>
/* Header for class android_luo_stone_facelandmarkdetection_NativeClass */

using namespace cv;
using namespace dlib;
using namespace std;

#ifndef _Included_android_luo_stone_facelandmarkdetection_NativeClass
#define _Included_android_luo_stone_facelandmarkdetection_NativeClass
#ifdef __cplusplus
extern "C" {
#endif

void faceDetectionDlib(Mat& img, Mat& dst);
void renderToMat(std::vector<full_object_detection>& dets,Mat& dst);
/*
* Class:     android_luo_stone_facelandmarkdetection_NativeClass
* Method:    getMessages
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_android_luo_stone_facelandmarkdetection_NativeClass_getMessages
  (JNIEnv *, jclass);

/*
* Class:     android_luo_stone_facelandmarkdetection_NativeClass
* Method:    LandmarkDetection
* Signature: (JJ)V
*/
JNIEXPORT void JNICALL Java_android_luo_stone_facelandmarkdetection_NativeClass_LandmarkDetection
  (JNIEnv *, jclass, jlong, jlong);

#ifdef __cplusplus
}
#endif
#endif



需要build的文件

需要build的文件

ndk-build运行出错

ndk-build运行出错
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

AndroidStudio中文社区 ( 京ICP备06021553号 )  

资源: 安卓 | Android | 社区 | 问答 | APP | WEB | SEO | ASO | 软件外包 |

© 2013-2014 Android Studio

快速回复 返回顶部 返回列表