Closed GoogleCodeExporter closed 9 years ago
How did you build JavaCV?
Original comment by samuel.a...@gmail.com
on 31 Aug 2013 at 7:05
I used this files from you download section: javacv-bin and javacv-cppjars
I deleted my project and I followed your instruction
now(http://code.google.com/p/javacv/). This is my library now:
bild1(also added the javacpp.jar and javacv.jar)
This is my program which I try to execute:
import static com.googlecode.javacv.cpp.opencv_core.cvCopy;
import static com.googlecode.javacv.cpp.opencv_core.cvLine;
import static com.googlecode.javacv.cpp.opencv_core.cvPoint;
import static com.googlecode.javacv.cpp.opencv_core.cvRect;
import static com.googlecode.javacv.cpp.opencv_core.cvResetImageROI;
import static com.googlecode.javacv.cpp.opencv_core.cvSetImageROI;
import static com.googlecode.javacv.cpp.opencv_highgui.CV_LOAD_IMAGE_GRAYSCALE;
import static com.googlecode.javacv.cpp.opencv_highgui.cvLoadImage;
import static com.googlecode.javacv.cpp.opencv_highgui.cvSaveImage;
import static com.googlecode.javacv.cpp.opencv_imgproc.CV_GRAY2BGR;
import static com.googlecode.javacv.cpp.opencv_imgproc.cvCvtColor;
import java.io.IOException;
import com.googlecode.javacv.ObjectFinder;
import com.googlecode.javacv.cpp.opencv_core.CvScalar;
import com.googlecode.javacv.cpp.opencv_core.IplImage;
public class GetSpielbrett {
static int tmp = 0;
static String hauptdatei = "IMAG0232";
static String objectFilename = "assets/sblinksoben.png";
static String datei = "sblinksoben";
static String objectFilename1 = "assets/sbrechtsunten.png";
static String datei1 = "sbrechtsunten";
static String objectFilename3 = "assets/sbobenrechts.jpg";
static String datei3 = "sbrechtsoben";
static String sceneFilename = "" + hauptdatei
+ ".PNG";
static String sceneFilename1 = "spielbrett-gedreht.png";
public static void bilderladen()
{
object = cvLoadImage(objectFilename,
CV_LOAD_IMAGE_GRAYSCALE);
object1 = cvLoadImage(objectFilename1,
CV_LOAD_IMAGE_GRAYSCALE);
object3 = cvLoadImage(objectFilename3,
CV_LOAD_IMAGE_GRAYSCALE);
image = cvLoadImage(sceneFilename, CV_LOAD_IMAGE_GRAYSCALE);
imageShow = cvLoadImage(sceneFilename);
sceneFilename = "" + hauptdatei
+ ".PNG";
image = cvLoadImage(sceneFilename, CV_LOAD_IMAGE_GRAYSCALE);
imageShow = cvLoadImage(sceneFilename);
}
}
Here is my MainActivitiy:
public class MainActivity extends Activity {
GetSpielbrett sander = new GetSpielbrett();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btnActivity = (Button)findViewById(R.id.button1);
btnActivity.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v) {
sander.bilderladen();
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
And I get this error message:
09-02 07:52:35.862: D/dalvikvm(1739): GC_CONCURRENT freed 188K, 11% free
2626K/2928K, paused 16ms+14ms, total 76ms
09-02 07:52:36.132: D/dalvikvm(1739): GC_CONCURRENT freed 319K, 14% free
2753K/3184K, paused 10ms+38ms, total 85ms
09-02 07:52:36.163: W/dalvikvm(1739): Exception
Ljava/lang/UnsatisfiedLinkError; thrown while initializing
Lcom/googlecode/javacv/cpp/opencv_core;
09-02 07:52:36.163: W/dalvikvm(1739): Exception
Ljava/lang/ExceptionInInitializerError; thrown while initializing
Lcom/googlecode/javacv/cpp/opencv_imgproc;
09-02 07:52:36.163: W/dalvikvm(1739): Exception
Ljava/lang/ExceptionInInitializerError; thrown while initializing
Lcom/googlecode/javacv/cpp/opencv_highgui;
09-02 07:52:36.163: D/AndroidRuntime(1739): Shutting down VM
09-02 07:52:36.163: W/dalvikvm(1739): threadid=1: thread exiting with uncaught
exception (group=0xb4da4908)
09-02 07:52:36.182: E/AndroidRuntime(1739): FATAL EXCEPTION: main
09-02 07:52:36.182: E/AndroidRuntime(1739):
java.lang.ExceptionInInitializerError
09-02 07:52:36.182: E/AndroidRuntime(1739): at
com.example.appseln.GetSpielbrett.bilderladen(GetSpielbrett.java:153)
09-02 07:52:36.182: E/AndroidRuntime(1739): at
com.example.appseln.MainActivity$1.onClick(MainActivity.java:24)
09-02 07:52:36.182: E/AndroidRuntime(1739): at
android.view.View.performClick(View.java:4202)
09-02 07:52:36.182: E/AndroidRuntime(1739): at
android.view.View$PerformClick.run(View.java:17340)
09-02 07:52:36.182: E/AndroidRuntime(1739): at
android.os.Handler.handleCallback(Handler.java:725)
09-02 07:52:36.182: E/AndroidRuntime(1739): at
android.os.Handler.dispatchMessage(Handler.java:92)
09-02 07:52:36.182: E/AndroidRuntime(1739): at
android.os.Looper.loop(Looper.java:137)
09-02 07:52:36.182: E/AndroidRuntime(1739): at
android.app.ActivityThread.main(ActivityThread.java:5039)
09-02 07:52:36.182: E/AndroidRuntime(1739): at
java.lang.reflect.Method.invokeNative(Native Method)
09-02 07:52:36.182: E/AndroidRuntime(1739): at
java.lang.reflect.Method.invoke(Method.java:511)
09-02 07:52:36.182: E/AndroidRuntime(1739): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
09-02 07:52:36.182: E/AndroidRuntime(1739): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
09-02 07:52:36.182: E/AndroidRuntime(1739): at
dalvik.system.NativeStart.main(Native Method)
09-02 07:52:36.182: E/AndroidRuntime(1739): Caused by:
java.lang.ExceptionInInitializerError
09-02 07:52:36.182: E/AndroidRuntime(1739): at
java.lang.Class.classForName(Native Method)
09-02 07:52:36.182: E/AndroidRuntime(1739): at
java.lang.Class.forName(Class.java:217)
09-02 07:52:36.182: E/AndroidRuntime(1739): at
com.googlecode.javacpp.Loader.load(Loader.java:453)
09-02 07:52:36.182: E/AndroidRuntime(1739): at
com.googlecode.javacv.cpp.opencv_highgui.<clinit>(opencv_highgui.java:85)
09-02 07:52:36.182: E/AndroidRuntime(1739): ... 13 more
09-02 07:52:36.182: E/AndroidRuntime(1739): Caused by:
java.lang.ExceptionInInitializerError
09-02 07:52:36.182: E/AndroidRuntime(1739): at
java.lang.Class.classForName(Native Method)
09-02 07:52:36.182: E/AndroidRuntime(1739): at
java.lang.Class.forName(Class.java:217)
09-02 07:52:36.182: E/AndroidRuntime(1739): at
com.googlecode.javacpp.Loader.load(Loader.java:453)
09-02 07:52:36.182: E/AndroidRuntime(1739): at
com.googlecode.javacv.cpp.opencv_imgproc.<clinit>(opencv_imgproc.java:97)
09-02 07:52:36.182: E/AndroidRuntime(1739): ... 17 more
09-02 07:52:36.182: E/AndroidRuntime(1739): Caused by:
java.lang.UnsatisfiedLinkError: Couldn't load jniopencv_core from loader
dalvik.system.PathClassLoader[dexPath=/data/app/com.example.appseln-1.apk,librar
yPath=/data/app-lib/com.example.appseln-1]: findLibrary returned null
09-02 07:52:36.182: E/AndroidRuntime(1739): at
java.lang.Runtime.loadLibrary(Runtime.java:365)
09-02 07:52:36.182: E/AndroidRuntime(1739): at
java.lang.System.loadLibrary(System.java:535)
09-02 07:52:36.182: E/AndroidRuntime(1739): at
com.googlecode.javacpp.Loader.loadLibrary(Loader.java:593)
09-02 07:52:36.182: E/AndroidRuntime(1739): at
com.googlecode.javacpp.Loader.load(Loader.java:489)
09-02 07:52:36.182: E/AndroidRuntime(1739): at
com.googlecode.javacpp.Loader.load(Loader.java:431)
09-02 07:52:36.182: E/AndroidRuntime(1739): at
com.googlecode.javacv.cpp.opencv_core.<clinit>(opencv_core.java:136)
09-02 07:52:36.182: E/AndroidRuntime(1739): ... 21 more
09-02 07:52:36.182: E/AndroidRuntime(1739): Caused by:
java.lang.UnsatisfiedLinkError: Couldn't load opencv_core from loader
dalvik.system.PathClassLoader[dexPath=/data/app/com.example.appseln-1.apk,librar
yPath=/data/app-lib/com.example.appseln-1]: findLibrary returned null
09-02 07:52:36.182: E/AndroidRuntime(1739): at
java.lang.Runtime.loadLibrary(Runtime.java:365)
09-02 07:52:36.182: E/AndroidRuntime(1739): at
java.lang.System.loadLibrary(System.java:535)
09-02 07:52:36.182: E/AndroidRuntime(1739): at
com.googlecode.javacpp.Loader.loadLibrary(Loader.java:593)
09-02 07:52:36.182: E/AndroidRuntime(1739): at
com.googlecode.javacpp.Loader.load(Loader.java:481)
09-02 07:52:36.182: E/AndroidRuntime(1739): ... 23 more
I hope its good enough for helping me. Thanks in advance.
Original comment by buchheim...@gmail.com
on 2 Sep 2013 at 8:04
Attachments:
The precompiled binaries probably won't work with OpenCV 2.4.6. You should try
2.4.5 as instructed in the README.txt file.
Original comment by samuel.a...@gmail.com
on 2 Sep 2013 at 8:16
I used the library from your downloadsection. They should be from 2.4.5 or not?
So I don't know what I made totally wrong.(I know there is something wrong but
I don't find where I did wrong ;))
Original comment by buchheim...@gmail.com
on 2 Sep 2013 at 8:33
I tried it with 2.3.1 and it's exact the same error.
Original comment by buchheim...@gmail.com
on 2 Sep 2013 at 9:34
Any other solution?
Original comment by buchheim...@gmail.com
on 3 Sep 2013 at 7:09
Have you tried with opencv-2.4.5-android-arm.jar as per the README.txt file ?
Original comment by samuel.a...@gmail.com
on 4 Sep 2013 at 1:09
Yes I did. I didn't even tried it with 2.4.6. Only with 2.4.5. But to be honest
I don't really understand this README.txt. You mean this README.txt right?
Original comment by buchheim...@gmail.com
on 4 Sep 2013 at 6:31
Attachments:
Ok, so did you make sure that your Android device has an ARMv7 CPU?
Original comment by samuel.a...@gmail.com
on 4 Sep 2013 at 6:33
I tried it with the emulator and with the new HTC ONE.
Original comment by buchheim...@gmail.com
on 4 Sep 2013 at 6:53
What does that mean when I don't have this CPU. It would't run with it?
Original comment by buchheim...@gmail.com
on 4 Sep 2013 at 6:55
Well then you libraries are obviously not getting installed on your device.
Have you tried to recreate your project? Android is very buggy, so ideally you
should also try to remove and reinstall *everything*.
Original comment by samuel.a...@gmail.com
on 4 Sep 2013 at 6:55
Yes, that's what "The binaries for Android were compiled for ARMv7 processors"
means.
Original comment by samuel.a...@gmail.com
on 4 Sep 2013 at 6:56
Is there a list which devices have ARMv7 precessors?
Original comment by buchheim...@gmail.com
on 4 Sep 2013 at 6:59
Anyways I gonna reinstall everthing and I will write the result. Firstly thanks.
Original comment by buchheim...@gmail.com
on 4 Sep 2013 at 7:13
Here's a good list:
http://en.wikipedia.org/wiki/Comparison_of_Android_devices
The emulator and HTC ONE have an ARMv7, so your problem is most likely Android
not building and installing your app properly. This is usually fixed by
recreating, uninstalling, and reinstalling various things related with the SDK,
your project, and your device...
Original comment by samuel.a...@gmail.com
on 4 Sep 2013 at 7:22
Finally this function runs. But there is another problem. I just splitted my
project in many functions to see where the problem is. Here is the code which
makes problems now:
public void sucher() throws InterruptedException
{
array = finden(object, image, imageShow, datei);
tmp++;
array3 = finden(object3, image, imageShow, datei3);
tmp++;
array1 = finden(object1, image, imageShow, datei1);
}
public static int[] finden(IplImage object, IplImage image,
IplImage imageShow, String datei) throws InterruptedException {
IplImage objectColor = IplImage.create(object.width(), object.height(),
8, 3);
cvCvtColor(object, objectColor, CV_GRAY2BGR);
IplImage correspond = IplImage.create(image.width(), object.height()
+ image.height(), 8, 1);
cvSetImageROI(correspond, cvRect(0, 0, object.width(), object.height()));
cvCopy(object, correspond);
cvSetImageROI(
correspond,
cvRect(0, object.height(), correspond.width(),
correspond.height()));
cvCopy(image, correspond);
cvResetImageROI(correspond);
ObjectFinder.Settings settings = new ObjectFinder.Settings();
settings.setObjectImage(object);
settings.setUseFLANN(true);
settings.setRansacReprojThreshold(5);
ObjectFinder finder = new ObjectFinder(settings);
long start = System.currentTimeMillis();
double[] dst_corners = finder.find(image);
System.out.println("Finding time = "
+ (System.currentTimeMillis() - start) + " ms");
int[] array = new int[2];
array[1] = 100000000;
array[0] = 100000000;
if (dst_corners != null) {
for (int i = 0; i < 4; i++) {
int j = (i + 1) % 4;
int x1 = (int) Math.round(dst_corners[2 * i]);
int y1 = (int) Math.round(dst_corners[2 * i + 1]);
int x2 = (int) Math.round(dst_corners[2 * j]);
int y2 = (int) Math.round(dst_corners[2 * j + 1]);
cvLine(correspond, cvPoint(x1, y1 + object.height()),
cvPoint(x2, y2 + object.height()), CvScalar.GREEN, 1,
8, 0);
cvLine(imageShow, cvPoint(x1, y1), cvPoint(x2, y2),
CvScalar.GREEN, 5, 8, 0);
// System.out.println("x1 :" + x1 + " y1 :" + y1);
if (tmp == 0 && i == 0) {
array[0] = x1;
array[1] = y1;
System.out.println("OBENLINKS: Koordinate x1: " + array[0]
+ " Koordinate y1: " + array[1]);
}
if (tmp == 1 && i == 1) {
array[0] = x1;
array[1] = y1;
System.out.println("OBENRECHTS: Koordinate x1: " + array[0]
+ " Koordinate y1: " + array[1]);
}
if (tmp == 2 && i == 2) {
array[0] = x1;
array[1] = y1;
System.out.println("UNTENRECHTS: Koordinate x1: "
+ array[0] + " Koordinate y1: " + array[1]);
tmp = 0;
}
}
}
cvSaveImage("" + datei
+ "-gefunden.jpg", imageShow);
return array;
}
Now I get this error:
09-04 11:52:38.894: D/AndroidRuntime(547): Shutting down VM
09-04 11:52:38.894: W/dalvikvm(547): threadid=1: thread exiting with uncaught
exception (group=0x409961f8)
09-04 11:52:38.913: E/AndroidRuntime(547): FATAL EXCEPTION: main
09-04 11:52:38.913: E/AndroidRuntime(547): java.lang.RuntimeException: Unable
to start activity
ComponentInfo{com.example.appseln2/com.example.appseln2.MainActivity}:
java.lang.NullPointerException
09-04 11:52:38.913: E/AndroidRuntime(547): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
09-04 11:52:38.913: E/AndroidRuntime(547): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
09-04 11:52:38.913: E/AndroidRuntime(547): at
android.app.ActivityThread.access$600(ActivityThread.java:122)
09-04 11:52:38.913: E/AndroidRuntime(547): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
09-04 11:52:38.913: E/AndroidRuntime(547): at
android.os.Handler.dispatchMessage(Handler.java:99)
09-04 11:52:38.913: E/AndroidRuntime(547): at
android.os.Looper.loop(Looper.java:137)
09-04 11:52:38.913: E/AndroidRuntime(547): at
android.app.ActivityThread.main(ActivityThread.java:4340)
09-04 11:52:38.913: E/AndroidRuntime(547): at
java.lang.reflect.Method.invokeNative(Native Method)
09-04 11:52:38.913: E/AndroidRuntime(547): at
java.lang.reflect.Method.invoke(Method.java:511)
09-04 11:52:38.913: E/AndroidRuntime(547): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
09-04 11:52:38.913: E/AndroidRuntime(547): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
09-04 11:52:38.913: E/AndroidRuntime(547): at
dalvik.system.NativeStart.main(Native Method)
09-04 11:52:38.913: E/AndroidRuntime(547): Caused by:
java.lang.NullPointerException
09-04 11:52:38.913: E/AndroidRuntime(547): at
com.example.appseln2.GetSpielbrett.finden(GetSpielbrett.java:258)
09-04 11:52:38.913: E/AndroidRuntime(547): at
com.example.appseln2.GetSpielbrett.sucher(GetSpielbrett.java:172)
09-04 11:52:38.913: E/AndroidRuntime(547): at
com.example.appseln2.MainActivity.onCreate(MainActivity.java:26)
09-04 11:52:38.913: E/AndroidRuntime(547): at
android.app.Activity.performCreate(Activity.java:4465)
09-04 11:52:38.913: E/AndroidRuntime(547): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
09-04 11:52:38.913: E/AndroidRuntime(547): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
09-04 11:52:38.913: E/AndroidRuntime(547): ... 11 more
Original comment by buchheim...@gmail.com
on 4 Sep 2013 at 11:58
Good to hear it's working!
As for the NullPointerException, well, you obviously have a NULL pointer
somewhere. Look around ActivityThread.java:1955 and fix it!
And please post your questions on the mailing list next time if possible, thank
you!
Original comment by samuel.a...@gmail.com
on 15 Sep 2013 at 4:14
Original issue reported on code.google.com by
buchheim...@gmail.com
on 29 Aug 2013 at 2:02