Configure Java CV with eclipse juno - eclipse

I am having a 64-bit windows 7 laptop.
I have opencv version 2.4.2. I have extracted it in the C:
I have eclipse juno classic on my laptop.
Jdk 7 64-bit version is installed and and path variable set so i can access javac from CMD.
I have javacv-0.2 downloaded from google projects.
for opencv i have added following path to the classpath variable.
C:\opencv\build\x64\vc10\bin;C:\opencv\build\common\tbb\intel64\vc10\
I have installed Microsoft Visual C++ 2010 Redistributable Package (x64)
I have inclused javacv.jar, javacpp.jar and javacv-windows-x86_64.jar in the ProjectBuildPath of eclipse.
Yet when i try to write following program function cvLoadImage(), cvSmooth(), cvSaveImage and cvReleaseImage() they are not identified and available to me.
import static com.googlecode.javacv.cpp.opencv_core.*;
import static com.googlecode.javacv.cpp.opencv_imgproc.*;
import static com.googlecode.javacv.cpp.opencv_highgui.*;
public class ssss {
public static void main(String filename) {
IplImage image = cvLoadImage(filename);
if (image != null) {
cvSmooth(image, image, CV_GAUSSIAN, 3);
cvSaveImage(filename, image);
cvReleaseImage(image);
}
}
}
Please guide me. If you need any other information regarding it do let know.
I followed the instruction available at this link to configure java-cv: http://ganeshtiwaridotcomdotnp.blogspot.in/2011/12/opencv-javacv-eclipse-project.html
Regards,
Priyank

You have mentioned that you are using 64bit system. But you have set path for 32bit binaries. correct path for 64 bit system should be
C:\opencv\build\x64\vc10\bin;C:\opencv\build\common\tbb\intel64\vc10\

Related

Arduino Linux mint: error: ‘digitalPinToInterrupt’

I wanted to interrupt a simple squared voltage and I was using a common program:
const byte ledPin = 13;
const byte interruptPin = 2;
volatile byte state = LOW;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(interruptPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(interruptPin), blink, CHANGE);
}
void loop() {
digitalWrite(ledPin, state);
}
void blink() {
state = !state;
}
But if I want to verify it with the Arduino Software, this is the error:
interrupt.ino: In function ‘void setup()’:
interrupt.ino:11:53: error: ‘digitalPinToInterrupt’ was not declared in this scope
I already tried adding libraries, which include this command, but I had problems finding them.
I am using Linux mint and the Arduino software version is:
arduino:
Installed: 2:1.0.5+dfsg2-4
Candidate: 2:1.0.5+dfsg2-4
Version table:
*** 2:1.0.5+dfsg2-4 500
And I couldn't install the IDE which I downloaded from https://www.arduino.cc
So this is the version of the package manager in Linux mint.
My question now is, does someone know where to find the libary which includes digitalPinToInterrupt().
There is no libary manager in this version of IDE, so perhaps someone knows how to get a newer version of IDE for Linuxmint.
Thank you
SOLVED
The version 1.8.2 for Linux 64bit on https://www.arduino.cc/en/Main/Software is defective. I found an other one on http://www.arduino.org/downloads.
This version also already includes digitalPinToInterrupt().

Fatal error when running a JavaFX GUI app inside Eclipse in a Docker container

Eclipse is working fine inside the container and its window is visible on the host (with the X11 being shared through socket).
The app is an Eclipse RCP project using JavaFX (Efxclipse and M2Eclipse). I removed all the references for the RCP below to have less complexity in the example and because it happens with really simple JavaFX apps (non-OSGI) as well - so OSGI isn't the issuer.
The following fatal error is happening when running a JavaFX GUI app inside Eclipse (inside a Docker container).
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f56bb14dd20, pid=233, tid=0x00007f567cea1700
#
# JRE version: Java(TM) SE Runtime Environment (8.0_111-b14) (build 1.8.0_111-b14)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.111-b14 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C [ld-linux-x86-64.so.2+0x9d20]
#
# Core dump written. Default location: /home/docker/test/JavaFX/login/core or core.233
#
# An error report file with more information is saved as:
# /home/docker/test/JavaFX/login/hs_err_pid233.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.java.com/bugreport/crash.jsp
#
The full log can be found here.
Host details:
Ubuntu 16.10
Docker version 1.12.3, build 6b644ec
Container details:
Ubuntu 16.04
Oracle JDK 1.8.0_111 64bits
Eclipse Luna (RCP 4.4.2) with e(fx)clipse 1.2.0.201501301049
Dockerfile
Code for the JavaFX app:
package application;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
public class Main extends Application {
#Override
public void start(Stage primaryStage) {
try {
Scene scene = new Scene(new BorderPane(),400,400);
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
launch(args);
}
}
Although I had success running a simple GUI app using Swing:
package application;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class Test {
private static void createAndShowGUI() {
JFrame frame = new JFrame("Test");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(500, 500);
JLabel label = new JLabel("Test");
frame.getContentPane().add(label);
frame.setVisible(true);
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
and this lead us to some problem related to JavaFX.
Even running an exported JavaFX app (as a Jar file) on the console (outside Eclipse) it's returning the same error.
Ideas on how to solve it and have the JavaFX app running inside Eclipse in the container?
Thanks
The problem was related to few missing dependencies in my Ubuntu image. Without them I was not able to run JavaFX apps in a Docker container.
Installing the following packages solved the problem:
gtk2-engines
libswt-gtk-3-java
libxslt1.1
libxtst6
libxxf86vm1
I tried to install only one or two of them (a sort of combination) in an attempt to find out which one exactly is needed but it turned out to be time consuming so I'm installing all of them - for now.
I found the solution on this Dockerfile when searching for examples on Github. Thanks Patrick Martin.

Error in running a plugin in imageJ

I am using imageJ (Fiji) version: 2.0.0-rc-43/1.50e
I installed a IHC_Profiler (https://sourceforge.net/projects/ihcprofiler/)
And when I run it, it shows a console with this:
Compiling 1 file in
/var/folders/k2/kdrnsbws5gz8vrt83yjmlbdm0000gn/T/java744586229414007803
/var/folders/k2/kdrnsbws5gz8vrt83yjmlbdm0000gn/T/java744586229414007803/src/main/java/IHC_Profiler.java:10: cannot access java.lang.Object
bad class file:
ZipFileIndexFileObject[/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/lib/ct.sym(META-INF/sym/rt.jar/java/lang/Object.class)]
class file has wrong version 52.0, should be 50.0
Please remove or make sure it appears in the correct subdirectory of the classpath.
public class IHC_Profiler implements PlugIn {
When I use imageJ 1.48 version, it is okay. I wonder if this problem can be solved?
You are running Fiji with Java 8, but without the Java-8 update site enabled.
The easiest solution is to download a fresh Fiji, which comes with the Java-8 update site enabled out of the box.
See this guide for details:
http://imagej.net/2016-05-10_-_ImageJ_HOWTO_-_Java_8,_Java_6,_Java_3D

How does cdt build environment populate the path?

Does anybody know how Eclipse CDT populate the path variable when the origin is "BUILD SYSTEM"? I thought through the global environment, but my system path is set to visual studio 2010 and somehow cdt find visual studio 2012 and will not compile for 2010.
path shown by process explorer (c:\apps\MVS10)
path detected by cdt (c:\apps\MVS11):
I'm using eclipse Luna 20140612-0600 + CDT 8.4.0.201406111759
After more googling, I found this bug report https://bugs.eclipse.org/bugs/show_bug.cgi?id=357980.
So CDT is hardcoded to detect Visual Studio through the registry and it uses the latest that it found and there's is no way (to my knowledge) in Eclipse to change it to a different version without hardcoding the path to the project; which I can't do because I'm not the only person working on the project.
WinEnvironmentVariableSupplier.java
private static String getVCDir() {
WindowsRegistry reg = WindowsRegistry.getRegistry();
String vcDir = getSoftwareKey(reg, "Microsoft\\VisualStudio\\SxS\\VC7", "11.0");
if (vcDir != null)
return vcDir;
vcDir = getSoftwareKey(reg, "Microsoft\\VisualStudio\\SxS\\VC7", "10.0");
if (vcDir != null)
return vcDir;
return getSoftwareKey(reg, "Microsoft\\VisualStudio\\SxS\\VC7", "9.0");
}
My workaround for this problem is to redefine the wrong variables to Eclipse's variables; just make sure to call vcvarsall.bat before launching Eclipse:
INCLUDE = ${INCLUDE}
LIB = ${LIB}
PATH = ${PATH}

DllNotFoundException in unity3d plugin for c++ dll

I am working on the Unity Plugin project and try to import the c++ native dll from c# file.
But I keep getting dllnotfoundexception.
c++ dll code:
extern "C" {
extern __declspec( dllexport ) bool IGP_IsActivated();
}
c# code:
[DllImport("mydll")]
private static extern bool IGP_IsActivated();
Dll is in place and FIle.Exists work properly. All dependent dlls are present at same hierarchy, but I still end up in dllnotfound exception.
Any help, much appreciated!!
Thanks to this Unity forum post I came up with a nice solution which modifies the PATH-environment variable at runtime:
Put all DLLs (both the DLLs which Unity interfaces with and their dependent DLLs) in Project\Assets\Wherever\Works\Best\Plugins.
Put the following static constructor into a class which uses the plugin:
static MyClassWhichUsesPlugin() // static Constructor
{
var currentPath = Environment.GetEnvironmentVariable("PATH",
EnvironmentVariableTarget.Process);
#if UNITY_EDITOR_32
var dllPath = Application.dataPath
+ Path.DirectorySeparatorChar + "SomePath"
+ Path.DirectorySeparatorChar + "Plugins"
+ Path.DirectorySeparatorChar + "x86";
#elif UNITY_EDITOR_64
var dllPath = Application.dataPath
+ Path.DirectorySeparatorChar + "SomePath"
+ Path.DirectorySeparatorChar + "Plugins"
+ Path.DirectorySeparatorChar + "x86_64";
#else // Player
var dllPath = Application.dataPath
+ Path.DirectorySeparatorChar + "Plugins";
#endif
if (currentPath != null && currentPath.Contains(dllPath) == false)
Environment.SetEnvironmentVariable("PATH", currentPath + Path.PathSeparator
+ dllPath, EnvironmentVariableTarget.Process);
}
Add [InitializeOnLoad] to the class to make sure that the constructor is run at editor launch:
[InitializeOnLoad]
public class MyClassWhichUsesPlugin
{
...
static MyClassWhichUsesPlugin() // static Constructor
{
...
}
}
With this script there is no need to copy around DLLs. The Unity editor finds them in the Assets/.../Plugins/...-folder and the executable finds them in ..._Data/Plugins-directory (where they get automatically copied when building).
Well I got it working.
For others who may face this problem, if you have more than one dll, you need to put the secondary dlls at root level of the Unity editor (e.g. C:\Program Files\Unity\Editor) and the actual referenced dll from script into plugins folder.
This worked for me.
Put the DLL(s) Unity interfaces with in Project\Assets\Wherever\Works\Best\Plugins.
Place any dependency DLLs that are not directly accessed by your scripts in Project. This will allow your program to run in the editor.
When you build, again copy the dependency DLL files, this time to the root of the build directory (right next to the generated executable). This should allow your application to load them at runtime.
(Tip: you can use Dependency Walker look at you DLLs and see what they depends on.)
I spent one day with this error. My issue was that Android doesn't get the library and always get and DDLNotFound error. My solution was:
1.- Be sure that you have the libraries for the proper architecture in the Plugins folder.
Plugins/Android/x86 and Plugins/Android/armeabi-v7a if your build settings is FAT(x86&arm)
2.- Check that Unity recognizes them as libraries. If you select them in the Project tab you should see them as a library and the platform and architecture related.
3.- After the build (don't close Unity Editor!), you can check in the Temp/StagingArea/libs if your libraries are there. If there are there for sure the libraries are going to be in the APK. As a double check, you can open your APK (change to zip extension) and see the libraries in the lib folder.
4.- In C# you should remove any lib prefix in your library name, for example:
If your library name is "libdosomething.so" you should call it as
[DllImport ("dosomething")]
I hope this work for you :)
Cheers.
Make sure the following chacklist is satisfied:
Plugins should all stay in a folder called Plugins.
The architecture your dll is built for (x86 or x86_64) must correspond to the architecture version of Unity Editor. Unity Editor 32-bit will not load 64 bit plugins and viceversa.
If you are targeting both 32 and 64 bit architectures you should put your dlls in special named folders inside the Plugins folder. The names are Plugins/x86 for 32 bit dlls and Plugins/x86_64 (x64 also works) for 64 bit dlls.
Visual C++ Redistributables must be installed. I have all from 2008.
When you build all your dlls should be copied into the root where your executable is (and again built for the correct x86/x64 architecture)
If you keep getting a namespace error it means the dll you are importing has unmanaged code and it must be wrapped into another managed dll Pugin in order to work.
These threads are a bit outdated but still relevant
DLLNotFoundException - Unity3D Plugin
Unity internal compiler error with custom dll
In my case, I have DllNotFoundException: ovrplatiformloader
Unity : DllNotFoundException: ovrplatformloader
Unity : at (wrapper managed-to-native) Oculus.Platform.CAPI.ovr_UnityInitWrapperAsynchronous(string)
Unity : at Oculus.Platform.AndroidPlatform.AsyncInitialize (System.String appId) [0x00013] in <29065e843b82403894fca6c6f2974090>:0
Unity : at Oculus.Platform.Core.AsyncInitialize (System.String appId) [0x0004f] in <29065e843b82403894fca6c6f2974090>:0
Unity : at DBHelper.Start () [0x00019] in <29065e843b82403894fca6c6f2974090>:0
My solution is:
Re-import files that doesn't work (libovrplatformloader.so)
Reconstruct the Platform/Plugins architecture. Old: Platform/Plugins/Android32/libovrplatformloader.so. New: Platform/Plugins/Android/x86/libovrplatformloader.so and Platform/Plugins/Android/armeabi-v7a/libovrplatformloader.so
Modify the import setting of libovrplatformloader.so. Change any platform to only Android platform and enable 'load on startup' selection. Choose ARMv7 CPU in armeabit-v7a while choose x86 CPU in x86 folder.
just put the dlls under Plugins folder and that works for me
I was having the same issue, and the solutions described here didn't work.
I think my case was a little different.
I think that the .dll I was importing depended on other .dll files. So I imported the other files related to that .dll (which I thought were unnecessary since I am not calling them directly on c# code) and that solved the issue.