0

I have a C++ program that starts like this:

#include "opencv2/highgui/highgui.hpp"
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <vector>
#include <stdio.h>
#include "linefinder.h"

#define PI 3.1415926

using namespace cv;

int main(int argc, char* argv[]) {
    int houghVote = 200;
    string arg = argv[1];
    bool showSteps = argv[2];

    string window_name = "Processed Video";
    namedWindow(window_name, CV_WINDOW_KEEPRATIO); //resizable window;
    VideoCapture capture(arg);

I want to make an Android app from it. I have NDK installed but I don't know what I have to do now.

Do I have to change anything in the C++ main program so that it will run on Android, or can I compile and run it unchanged?

2
  • 1
    docs.opencv.org/doc/tutorials/introduction/… Commented Aug 10, 2014 at 1:58
  • Yes, I already check that page, but it doesn't help. I have programs as face detection running, but I don't know how to do use my own C++ code into Android program Commented Aug 10, 2014 at 19:53

1 Answer 1

1

Introduction to Android

Android provides a rich application framework that allows you to build innovative apps and games for mobile devices in a Java language environment. ... Android apps are built as a combination of distinct components that can be invoked individually.

You need to construct your app using Java, then call your C++ code via JNI.

Also, Android NDK has this to say

you should only use the NDK if it is essential to your app—never because you simply prefer to program in C/C++

In particular, read Using the NDK to understand why you can't run your C++ main program without changing anything.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.