2017-06-11 14 views
0

ありません私はgithubのから、プロジェクトのテストをダウンロードして、私はアプリを実行したいとき、私は画像リンクError ReportそのようなファイルやディレクトリC++

アプリのGradleの中で、このエラーを取得する:

apply plugin: 'com.android.model.application' 

model { 
repositories { 
    libs(PrebuiltLibraries) { 
     prebuilt { 
      headers.srcDir "../../../package/include" 
      binaries.withType(SharedLibraryBinary) { 
       sharedLibraryFile = file("../../../package/Android/libs/armeabi-v7a/libEasyAR.so") 
      } 
     } 
    } 
} 
android { 
    compileSdkVersion = 25 
    buildToolsVersion = "25.0.2" 

    defaultConfig.with { 
     applicationId = "com.jerome.unitydemo" 
     minSdkVersion.apiLevel = 15 
     targetSdkVersion.apiLevel = 22 
     versionCode = 1 
     versionName = "1.0" 
    } 



    sources { 
     main { 

      jni { 
       dependencies { 
        library "prebuilt" 
       } 

      } 
     } 
    } 
} 
android.buildTypes { 
    release { 
     minifyEnabled = false 
     proguardFiles.add(file("proguard-rules.pro")) 
    } 
} 
android.ndk { 
    moduleName = "HelloARVideoNative" 
    cppFlags.add("-I${file("../../../package/include")}".toString()) 
    cppFlags.add("-DANDROID") 
    cppFlags.add("-fexceptions") 
    cppFlags.add("-frtti") 
    stl = "gnustl_static" 
    ldLibs.add("log") 
    ldLibs.add("GLESv2") 
} 

android.productFlavors { 
    create("arm") { 
     ndk.with { 
      abiFilters.add("armeabi-v7a") 
     } 
    } 

} 
} 

dependencies { 
compile fileTree(include: ['*.jar'], dir: 'libs') 
compile 'com.android.support:appcompat-v7:25.1.1' 
} 

Android.mk

LOCAL_PATH_TOP := $(call my-dir) 
EASYAR_PACKAGE_PATH := $(LOCAL_PATH_TOP)/../../../../../../package 

include $(CLEAR_VARS) 
LOCAL_PATH := $(EASYAR_PACKAGE_PATH)/Android/libs/armeabi-v7a 
LOCAL_MODULE:=libEasyAR 
LOCAL_SRC_FILES:=libEasyAR.so 
include $(PREBUILT_SHARED_LIBRARY) 

include $(CLEAR_VARS) 
LOCAL_PATH := $(LOCAL_PATH_TOP) 
LOCAL_C_INCLUDES += $(EASYAR_PACKAGE_PATH)/include 
LOCAL_CPPFLAGS += -DANDROID 
LOCAL_LDLIBS += -llog -lGLESv2 
LOCAL_SHARED_LIBRARIES += libEasyAR 
LOCAL_CPP_EXTENSION := .cc 
LOCAL_MODULE := libHelloARNative 
LOCAL_SRC_FILES := ar.cc helloarvideo.cc renderer.cc 
include $(BUILD_SHARED_LIBRARY) 

Application.mk

APP_OPTIM := release 
APP_PLATFORM := android-17 
APP_STL := gnustl_static 
APP_ABI := armeabi-v7a 
APP_MODULES := HelloARNative 
NDK_TOOLCHAIN := arm-linux-androideabi-4.9 

そして、この私がどんな結果なしでこのエラーに苦しんでいた私のJNIProject structure

内のファイルのすべてが助けてください。

ar.hpp

#ifndef __EASYAR_SAMPLE_UTILITY_AR_H__ 
#define __EASYAR_SAMPLE_UTILITY_AR_H__ 

#include "easyar/camera.hpp" 
#include "easyar/imagetracker.hpp" 
#include "easyar/augmenter.hpp" 
#include "easyar/imagetarget.hpp" 
#include "easyar/frame.hpp" 
#include "easyar/player.hpp" 
#include "easyar/utility.hpp" 
#include <string> 

namespace EasyAR{ 
namespace samples{ 

class AR 
{ 
public: 
AR(); 
virtual ~AR(); 
virtual bool initCamera(); 
virtual void loadFromImage(const std::string& path); 
virtual void loadFromJsonFile(const std::string& path, const std::string&  targetname); 
virtual void loadAllFromJsonFile(const std::string& path); 
virtual bool start(); 
virtual bool stop(); 
virtual bool clear(); 

virtual void initGL(); 
virtual void resizeGL(int width, int height); 
virtual void render(); 
void setPortrait(bool portrait); 
protected: 
CameraDevice camera_; 
ImageTracker tracker_; 
Augmenter augmenter_; 
bool portrait_; 
Vec4I viewport_; 
}; 

class ARVideo { 
public: 
ARVideo(); 
~ARVideo(); 

void openVideoFile(const std::string& path, int texid); 
void openTransparentVideoFile(const std::string& path, int texid); 
void openStreamingVideo(const std::string& url, int texid); 

void setVideoStatus(VideoPlayer::Status status); 
void onFound(); 
void onLost(); 
void seek(int pos); 
int currentPosition(); 
int duration(); 
bool pause(); 
bool play(); 
void update(); 

class CallBack : public VideoPlayerCallBack 
{ 
public: 
    CallBack(ARVideo* video); 
    void operator() (VideoPlayer::Status status); 
private: 
    ARVideo* video_; 
}; 

private: 
VideoPlayer player_; 
bool prepared_; 
bool found_; 
CallBack* callback_; 
std::string path_; 
}; 

} 
} 
#endif 

ar.cc

#include "ar.hpp" 
#include <algorithm> 
#ifdef ANDROID 
#include <android/log.h> 
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO, "EasyAR", __VA_ARGS__) 
#else 
#define LOGI(...) printf(__VA_ARGS__) 
#endif 

namespace EasyAR{ 
namespace samples{ 

class HelloCallBack : 
public TargetLoadCallBack 
{ 
public: 
virtual ~HelloCallBack() { 
}; 
virtual void operator() (const Target target, const bool status) 
{ 
LOGI("load target: %s (%d) %s\n", target.name(), target.id(), status ? "success" : "fail"); 
delete this; 
} 
}; 

AR::AR() 
{ 
portrait_ = false; 
} 

AR::~AR() 
{ 
clear(); 
} 

bool AR::initCamera() 
{ 
bool status = true; 
status &= camera_.open(); 
camera_.setSize(Vec2I(1280, 720)); 
status &= tracker_.attachCamera(camera_); 
status &= augmenter_.attachCamera(camera_); 
return status; 
} 


void AR::loadFromImage(const std::string& path) 
{ 
ImageTarget target; 
std::string jstr = "{\n" 
" \"images\" :\n" 
" [\n" 
" {\n" 
"  \"image\" : \"" + path + "\",\n" 
"  \"name\" : \"" + path.substr(0, path.find_first_of(".")) + "\"\n" 
" }\n" 
" ]\n" 
"}"; 
target.load(jstr.c_str(), EasyAR::kStorageAssets | EasyAR::kStorageJson); 
tracker_.loadTarget(target, new HelloCallBack()); 
} 

void AR::loadFromJsonFile(const std::string& path, const std::string& targetname) 
{ 
ImageTarget target; 
target.load(path.c_str(), EasyAR::kStorageAssets, targetname.c_str()); 
tracker_.loadTarget(target, new HelloCallBack()); 
} 

void AR::loadAllFromJsonFile(const std::string& path) 
{ 
TargetList targets = ImageTarget::loadAll(path.c_str(), EasyAR::kStorageAssets); 
for (int i = 0; i < targets.size(); ++i) { 
tracker_.loadTarget(targets[i], new HelloCallBack()); 
} 
} 

bool AR::start() 
{ 
bool status = true; 
status &= camera_.start(); 
camera_.setFocusMode(CameraDevice::kFocusModeContinousauto); 
status &= tracker_.start(); 
return status; 
} 



bool AR::stop() 
{ 
bool status = true; 
status &= tracker_.stop(); 
status &= camera_.stop(); 
return status; 
} 

bool AR::clear() 
{ 
bool status = true; 
status &= stop(); 
status &= camera_.close(); 
camera_.clear(); 
tracker_.clear(); 
augmenter_.clear(); 
return status; 
} 

void AR::resizeGL(int width, int height) 
{ 
Vec2I size = Vec2I(1, 1); 
if (camera_.isOpened()) 
size = camera_.size(); 
if (size[0] == 0 || size[1] == 0) 
return; 
if (portrait_) 
std::swap(size[0], size[1]); 
float scaleRatio = std::max((float)width/(float)size[0], (float)height/(float)size[1]); 
Vec2I viewport_size = Vec2I((int)(size[0] * scaleRatio), (int)(size[1] * scaleRatio)); 
viewport_ = Vec4I(0, height - viewport_size[1], viewport_size[0],  viewport_size[1]); 
    } 

void AR::initGL() 
{ 

} 

void AR::render() 
{ 

} 

void AR::setPortrait(bool portrait) 
{ 
portrait_ = portrait; 
} 

ARVideo::ARVideo() 
{ 
prepared_ = false; 
found_ = false; 
callback_ = NULL; 
} 

ARVideo::~ARVideo() 
{ 
player_.close(); 
if (callback_) 
delete callback_; 
} 

void ARVideo::openVideoFile(const std::string& path, int texid) 
{ 
if (!callback_) 
callback_ = new CallBack(this); 
path_ = path; 
player_.setRenderTexture(texid); 
player_.setVideoType(VideoPlayer::kVideoTypeNormal); 
player_.open(path.c_str(), kStorageAssets, callback_); 

} 

void ARVideo::openTransparentVideoFile(const std::string& path, int texid) 
{ 
if (!callback_) 
callback_ = new CallBack(this); 
path_ = path; 
player_.setRenderTexture(texid); 
player_.setVideoType(VideoPlayer::kVideoTypeTransparentSideBySide); 
player_.open(path.c_str(), kStorageAssets, callback_); 
} 

void ARVideo::openStreamingVideo(const std::string& url, int texid) 
{ 
if (!callback_) 
callback_ = new CallBack(this); 
path_ = url; 
player_.setRenderTexture(texid); 
player_.setVideoType(VideoPlayer::kVideoTypeNormal); 
player_.open(url.c_str(), kStorageAbsolute, callback_); 
} 

void ARVideo::setVideoStatus(VideoPlayer::Status status) 
{ 
LOGI("video: %s (%d)\n", path_.c_str(), status); 
if (status == VideoPlayer::kVideoReady) { 
prepared_ = true; 
if (found_) 
player_.play(); 
} 
if (status == VideoPlayer::kVideoCompleted) { 
if (found_) 
player_.play(); 
} 
} 

void ARVideo::onFound() 
{ 
found_ = true; 
if (prepared_) { 
player_.play(); 
} 
} 

void ARVideo::onLost() 
{ 
found_ = false; 
if (prepared_) 
player_.pause(); 
} 
int ARVideo::duration(){ 
if (prepared_) { 
return player_.duration(); 
}else{ 
return 0; 
} 
} 
int ARVideo::currentPosition(){ 
if (prepared_) { 
return player_.currentPosition(); 
}else{ 
return 0; 
} 
} 
bool ARVideo::pause(){ 
if (prepared_) 
player_.pause(); 
return false; 
} 

bool ARVideo::play(){ 
if (prepared_) 
return player_.play(); 
return false; 
} 

void ARVideo::seek(int pos){ 
if(prepared_){ 
    player_.seek(pos); 
} 
} 


void ARVideo::update() 
{ 
player_.updateFrame(); 
} 

ARVideo::CallBack::CallBack(ARVideo* video) 
{ 
video_ = video; 
} 

void ARVideo::CallBack::operator() (VideoPlayer::Status status) 
{ 
video_->setVideoStatus(status); 
} 

} 
} 

renderer.hpp

#ifndef __EASYAR_SAMPLE_UTILITY_SIMPLERENDERER_H__ 
#define __EASYAR_SAMPLE_UTILITY_SIMPLERENDERER_H__ 

#include "easyar/matrix.hpp" 

namespace EasyAR{ 
namespace samples{ 

class VideoRenderer 
{ 
public: 
void init(); 
void render(const Matrix44F& projectionMatrix, const Matrix44F& cameraview, Vec2F size); 
unsigned int texId(); 
private: 
unsigned int program_box; 
int pos_coord_box; 
int pos_tex_box; 
int pos_trans_box; 
int pos_proj_box; 
unsigned int vbo_coord_box; 
unsigned int vbo_tex_box; 
unsigned int vbo_faces_box; 
unsigned int texture_id; 
}; 

} 
} 
#endif 

レンダリングer.cc

#include "renderer.hpp" 
#if defined __APPLE__ 
#include <OpenGLES/ES2/gl.h> 
#else 
#include <GLES2/gl2.h> 
#endif 

const char* box_video_vert="uniform mat4 trans;\n" 
     "uniform mat4 proj;\n" 
     "attribute vec4 coord;\n" 
     "attribute vec2 texcoord;\n" 
     "varying vec2 vtexcoord;\n" 
     "\n" 
     "void main(void)\n" 
     "{\n" 
     " vtexcoord = texcoord;\n" 
     " gl_Position = proj*trans*coord;\n" 
     "}\n" 
     "\n" 
; 

const char* box_video_frag="#ifdef GL_ES\n" 
     "precision highp float;\n" 
     "#endif\n" 
     "varying vec2 vtexcoord;\n" 
     "uniform sampler2D texture;\n" 
     "\n" 
     "void main(void)\n" 
     "{\n" 
     " gl_FragColor = texture2D(texture, vtexcoord);\n" 
     "}\n" 
     "\n" 
; 

namespace EasyAR{ 
namespace samples{ 

void VideoRenderer::init() 
{ 
    program_box = glCreateProgram(); 
    GLuint vertShader = glCreateShader(GL_VERTEX_SHADER); 
    glShaderSource(vertShader, 1, &box_video_vert, 0); 
    glCompileShader(vertShader); 
    GLuint fragShader = glCreateShader(GL_FRAGMENT_SHADER); 
    glShaderSource(fragShader, 1, &box_video_frag, 0); 
    glCompileShader(fragShader); 
    glAttachShader(program_box, vertShader); 
    glAttachShader(program_box, fragShader); 
    glLinkProgram(program_box); 
    glUseProgram(program_box); 
    pos_coord_box = glGetAttribLocation(program_box, "coord"); 
    pos_tex_box = glGetAttribLocation(program_box, "texcoord"); 
    pos_trans_box = glGetUniformLocation(program_box, "trans"); 
    pos_proj_box = glGetUniformLocation(program_box, "proj"); 

    glGenBuffers(1, &vbo_coord_box); 
    glBindBuffer(GL_ARRAY_BUFFER, vbo_coord_box); 
    const GLfloat cube_vertices[4][3] = {{1.0f/2, 1.0f/2, 0.f},{1.0f/2, -1.0f/2, 0.f},{-1.0f/2, -1.0f/2, 0.f},{-1.0f/2, 1.0f/2, 0.f}}; 
    glBufferData(GL_ARRAY_BUFFER, sizeof(cube_vertices), cube_vertices, GL_DYNAMIC_DRAW); 

    glGenBuffers(1, &vbo_tex_box); 
    glBindBuffer(GL_ARRAY_BUFFER, vbo_tex_box); 
    const GLubyte cube_vertex_texs[4][2] = {{0, 0},{0, 1},{1, 1},{1, 0}}; 
    glBufferData(GL_ARRAY_BUFFER, sizeof(cube_vertex_texs), cube_vertex_texs, GL_STATIC_DRAW); 

    glGenBuffers(1, &vbo_faces_box); 
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo_faces_box); 
    const GLushort cube_faces[] = {3, 2, 1, 0}; 
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(cube_faces), cube_faces, GL_STATIC_DRAW); 

    glUniform1i(glGetUniformLocation(program_box, "texture"), 0); 
    glGenTextures(1, &texture_id); 
    glBindTexture(GL_TEXTURE_2D, texture_id); 
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); 
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); 
} 

void VideoRenderer::render(const Matrix44F& projectionMatrix, const Matrix44F& cameraview, Vec2F size) 
{ 
    glBindBuffer(GL_ARRAY_BUFFER, vbo_coord_box); 
    const GLfloat cube_vertices[4][3] = {{size[0]/2, size[1]/2, 0.f},{size[0]/2, -size[1]/2, 0.f},{-size[0]/2, -size[1]/2, 0.f},{-size[0]/2, size[1]/2, 0.f}}; 
    glBufferData(GL_ARRAY_BUFFER, sizeof(cube_vertices), cube_vertices, GL_DYNAMIC_DRAW); 

    glEnable(GL_BLEND); 
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 
    glEnable(GL_DEPTH_TEST); 
    glUseProgram(program_box); 
    glBindBuffer(GL_ARRAY_BUFFER, vbo_coord_box); 
    glEnableVertexAttribArray(pos_coord_box); 
    glVertexAttribPointer(pos_coord_box, 3, GL_FLOAT, GL_FALSE, 0, 0); 
    glBindBuffer(GL_ARRAY_BUFFER, vbo_tex_box); 
    glEnableVertexAttribArray(pos_tex_box); 
    glVertexAttribPointer(pos_tex_box, 2, GL_UNSIGNED_BYTE, GL_FALSE, 0, 0); 
    glUniformMatrix4fv(pos_trans_box, 1, 0, cameraview.data); 
    glUniformMatrix4fv(pos_proj_box, 1, 0, projectionMatrix.data); 
    glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo_faces_box); 
    glActiveTexture(GL_TEXTURE0); 
    glBindTexture(GL_TEXTURE_2D, texture_id); 
    glDrawElements(GL_TRIANGLE_FAN, 4, GL_UNSIGNED_SHORT, 0); 
    glBindTexture(GL_TEXTURE_2D, 0); 
} 

unsigned int VideoRenderer::texId() 
{ 
    return texture_id; 
} 

} 
} 

私は解決策を取得し、あなたの助けに感謝するために、これはコードがたくさんあると思いますけど。

+1

エラーログを見てくださいoutput.txtファイルのパスに行き、ここにコードをコピーしてコピーしてください。 –

+0

「ログ時にコンパイルする」を参照してください。output.txtファイルアドレス –

+0

あなたの.ccファイルと.hppファイルのコードを投稿してください。 –

答えて

0

物事は両方.HPPファイルにEasyAR.jarファイルのパスを確認し、include文(#include <string>を除くすべて)に 次試してみてください、このapp/libs/armeabi-v7a/easyar/cameraのようにパスを追加し、ここでアプリがフォルダならば(LIBSフォルダの親ディレクトリであります名前はアプリではありません)

何が起こっていますか? .hppファイルがEasyAR.jarからインクルードされているファイルのパスを取得していない場合、上記の方法でパスが変更されない場合は、パスを#include easyar/...に戻し、jarファイル(EasyAR.jar)をjniディレクトリに置きます。 動作しているかどうか教えてください

+0

ありがとうございますが、うまくいきません^^プロジェクトをここでテストしたいのですが、[link](https://github.com/Jerome-MJ/EasyARVideo)です。 – john

関連する問題