How to Use OpenCV Wait Key With Chaquopy - android

I am attempting to use Chaquopy to port a computer vision application to android. When I try to run my script the following error occurs on the following line:
cv2.waitKey(100)
The error which prints to the embedded python console is:
java.chaquopy.CQPEnv.check_exception
com.chaquo.python.PyException: error: OpenCV(3.4.2) /home/smith/git/chaquo/python/server/pypi/packages/opencv-python/build/3.4.2.16/cp36-cp36m-android_15_armeabi_v7a/src/opencv/modules/highgui/src/window.cpp:698: error: (-2:Unspecified error) The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script in function 'cvWaitKey'
I have installed openCV in the build gradle as follows:
pip {
install "opencv-python"
}
Which is according to the Chaquopy documentation found here:
Chaquopy openCV discussion

It looks like OpenCV only has support for key events on desktop platforms, not mobile ones. The same is probably true of all the other "High-level GUI" functions.
Anyway, unless your Android device actually has a keyboard, waiting for a keypress doesn't really make sense. You might be better off creating a simple Android UI like in the Chaquopy demo app, and interacting with the user that way.

Related

How to debug NativeScript java code in Android Studio?

I'm quite new to NativeScript. Currently, one of my projects is using NativeScript to develop cross-platform app. It has a 3rd-party lib which is written in java. But the result is not as good as I expected. I was struggling to find the problem since the console didn't log valuable info regarding to native code.
Instead, I import the project to Android Studio which is under the folder of platform/android. But it logs error when I hit the "run" button.
I want to know:
Is it possible to debug native code directly with VS Code. At least print out java native error or cat log.
How can I debug native code in Android Studio? How to solve the problem I ran into?
I'd be very appreciated, if anyone can answer my questions. Thanks!
Let me start off by saying there's no official integration with Android Studio. All I can provide is a workaround that will make it possible.
Note: The steps provided below are tested with NativeScript CLI 3.1.1 and will probably work also with 3.2.0.
The first problem is you don't have "node" set in your global path so first of all, you need to add it to PATH. Node required for NativeScript to run. You can look at how to set it up here
If you want to be able to run the project with Android Studio you can follow these steps:
After you've done that you need to change the <app_name>/platforms/android/build.gradle file as described here
The above change will enable you to open <app_name>/platforms/android in Android Studio
Run <app_name>:clean task from gradle
Run the task default for Android Studio, that will prompt you for emulator or device on which to run:

Running a go program on Android?

I have a go library that i want to run on android and use its methods in my android app. I could write the whole android app in go to make it easier to use this dependency. Is this possible? If so, how?
Download Termux (Linux Emulator) from google play store and open it.
Next, wait for it to perform an automatic download of its resources. After that operation, the run the following command:
pkg install golang
pkg install git
The got package is required when downloading golang packages.
Eventually, you can test it by running (go) command.
Golang support for mobile development has been steadily improving. Today it is even possible to build some simple all Go apps (depending on which features you need) as well as Go libraries. Please see https://github.com/golang/go/wiki/Mobile for more info.
UPDATE: In further improvement, libraries are being created to support even UI on mobile platforms. https://fyne.io provides rather robust set of features for mobile.
You can use a Go library from Java when developing for Android with gobind (see this example in the gomobile repository). The biggest issue with this is integration into the build system.
For Go 1.5 things are getting better, but you'll have to wait for that.

Use Sublime Text 2 to develop Phonegap applications for Android

I've been using eclipse to develop Android apps with phonegap until, a few weeks ago, I decided to try Sublime Text 2. I found it to be so much better than the eclipse editor so I would like to keep using it. Only thing I'm missing is a quick way to test the app on the device inside Sublime.
Luckily, someone else also had the same idea and developed a plugin for this:
https://github.com/Korcholis/Andrew
Sadly, I cannot get it to work, I installed ant and pointed the plugin to adb but then nothing happens when I try to create a new project (and there is no error message in the console).
I also found this other plugin:
https://bitbucket.org/ucomesdag/sublime-android
But I have no idea on how to install and run it.
Did someone else found a way to do this?
A quick update into 2014.
As of PhoneGap Cordova 3.0, it is no longer required to develop Android apps via eclipse. You are free to use any code editor or IDE you wish as app building is done independently from eclipse via a simple command line.
cordova run android to package the .apk and install on any active devices detected by adb or
cordova build android to package the .apk only.
In your case, you can keep using Sublime and pop in the cordova run android command whenever you ready to go on a test run.
While I agree with Insane Coder that you should stick with supported IDEs to develop for Android, according to this link and existing Sublime Text 2 Ant support, you could build and develop your android project with this IDE (It will just take some time to set it all up... as opposed to using a supported IDE like IntelliJ or Eclipse).
Using PackageControl, look for "Ant". That will install syntax highlighting for Ant. Another plugin that enables the build command (ctrl+b) to work for Ant files, "Super Ant". You should be able to code for android in sublime text 2 with those installed.
On another note... Do you use windows? The Andrew project you link to, seems to have Windows compatibility issues. Apparently related to locating the "SDK" (he says sdk in Andrew's github page but, probably he means JDK?) in your hard drive. Which is probably a hassle because Windows typically installs stuff to "Program Files" and in code, that turns into "Progra~1" because of the space. In the link I give you there is another approach to it, so when you install the JDK set a folder that has no spaces in its name, like c:\java\jdk1.6.0_02 or something else that strikes your fancy. The problem you could be having with Andrew is that it isn't finding the jdk in your hard disk.

Qt5 for Android: Project ERROR: Unknown module(s) in QT: quick qml

I built Qt5 for Android with the step by step tutorial from this link:
Building Qt 5 for Android.
Now, i'm able to build and deploy QWidget Applications to my nexus 7. But if i try to build a QtQuick Application with the given template of QtCreator 2.7.1, i get the following error:
Project ERROR: Unknown module(s) in QT: quick qml
I did every build step exactly as described in the tutorial. Has anybody else faced this error?
QtQuick works perfectly well with Qt5.2. My suggestion is that you built Qt5.2 from source, instead of simply installing it, i.e. you clone it from Gitorious. After you check all the details, once you put it to build, go for a coffee as it will take a while to finish it.
Also, have you installed the Android SDK and NDK? If not, my suggestion is that you install the Studio Android.
You will also have to be very careful in making all the environment setups for your cross-compiling tool-chain otherwise it will not work. Check in the sequence what I have for my development settings.
Ant is also part of the installation, as you probably won't wish to miss that.
In the end if you have done all the settings accordingly, without forgetting anything, then you just need to select Qt Quick Application.
And it will work, as qt quick is officially supported on Android Qt5.2.

Using mixed Java/Ruby code in an Android app?

Is it possible to write part of the Android app in Ruby and then, using JRuby and Android Tools, compile the code to run on Dalvik VM? I don't need any run-time support for interpreting Ruby code, just to run one Ruby module. It would be nice if the compiled code is minimal, to not drag along the entire Ruby standard library.
How to configure some IDE (like Eclipse) and Android Tools to support that?
See these/three/answers (on stackoverflow) regarding #CharlesOliverNutter 's Ruby-like Mirah language that runs on the Dalvik VM.
Have a look at Ruboto.
Some time ago I was working on a debug lib for android that was using it but I got out of time. I looked at the ruboto-irb source code a lot.
The major downside I came up is that it needed to have ruboto installed on the device.

Categories

Resources