I downloaded bytedeco's JavaCV from github and have included it into my dependencies for my IntelliJ project.
I then read through the documentation and the readme file and then figure out what I think were the proper import statements.
I have tried "import org.bytedeco.javacv.*;" from what I found in the package in the package names.
That did not work, IntelliJ could not resolve symbol "bytedeco". This happened even in the JavaCV classes that are a part of the org.bytedeco.javacv package did not resolve the import statements. I then went onto stack overflow to look for anyone who had the same problem or could solve my problem. I couldn't find any useful information at all about what is wrong.
I found this very confusing and could not find any other information onto why this is happening. This is my first project, I do not know if this is a limitation with IntelliJ or that I am missing some other package that isn't part of JavaCV or some other problem I do not yet know of.
That's right the correct package name should be org.bytedeco.opencv.global.opencv_core.*.
Here is a sample code taken from the GitHub:
import org.bytedeco.opencv.opencv_core.*;
import org.bytedeco.opencv.opencv_imgproc.*;
import static org.bytedeco.opencv.global.opencv_core.*;
import static org.bytedeco.opencv.global.opencv_imgproc.*;
import static org.bytedeco.opencv.global.opencv_imgcodecs.*;
public class Smoother {
public static void smooth(String filename) {
Mat image = imread(filename);
if (image != null) {
GaussianBlur(image, image, new Size(3, 3), 0);
imwrite(filename, image);
}
}
}
You may find the sample code on the official GitHub project site helpful for a fast start:
https://github.com/bytedeco/javacv/tree/master/samples
https://github.com/bytedeco/javacv#manual-installation
Related
i have been searching around for a few days for the answer to this and i just can't seem to get it to work. I have seen exact examples where it is working for them and I try exactly what they do and it is just not working for me.
Basically what i am trying to do is open a local access DB. I have tried numerous methods and this Jackcess seems by far the best library to use, so i am trying to get it to work with that. I have read their cookbook and gone through all of that, and still no luck so i am coming to you guys in the hope of finding a good solution (i have not posted this question anywhere yet). Here is my code (the relevant part)
The only syntax error i am getting is "DatabaseBuilder.Open" and the error is it cannot find the method, even though i have the libraries included for IO
import com.healthmarketscience.jackcess.*;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
Database db = DatabaseBuilder.open(new File("my.mdb"));
try {
Table table = db.getTable("Teams");
} catch (IOException ex) {
Logger.getLogger(Teams.class.getName()).log(Level.SEVERE, null, ex);
}
}
Any help would be greatly appreciated!
The program fails to debug once I have click this buttone the only actual message i can fine is
"Cannot find symbol
Symbol : Method Open(file)
Location : variable.DatabaseBuilder of type Object"
To use Jackcess you must have at least the following items in the build path for your Java project (or on your CLASSPATH):
the Jackcess JAR file itself, and
the JAR files for its two mandatory compile-time dependencies from Apache: commons-lang and commons-logging.
In the Eclipse IDE that will look something like this:
Hello i read that I have to use the java client library in java to get the revisions list in google drive using google api. I use netbeans. I search for this question and I try to add the bib but i haven't get success. To download the library i visited this link and downloaded the "latest". but after add the jar files I get the message error that the package doesnt exist. Please someone help me!
Yes! I try this but it show the same erros. I add the lib but netbeans (8) show the error in the three lines code: "package [name] doesn't exist".
The three lines are these:
import com.google.api.services.drive.Drive;
import com.google.api.services.drive.model.Revision;
import com.google.api.services.drive.model.RevisionList;
obs: the full code, taken in the google developers site is:
package javaapplication8;
import com.google.api.services.drive.Drive;
import com.google.api.services.drive.model.Revision;
import com.google.api.services.drive.model.RevisionList;
import java.io.IOException;
import java.util.List;
public class MyClass {
private static List<Revision> retrieveRevisions(Drive service,
String fileId) {
fileId = "1XpNdeTFBr2KygyfPtlowBvkpcaJJzjgLckrGjp5oOhg0";
try {
RevisionList revisions = service.revisions().list(fileId).execute();
return revisions.getItems();
} catch (IOException e) {
System.out.println("An error occurred: " + e);
}
return null;
}
}
If it is the error like package is missing, please check whether you have created a folder named com in your project or not. Also, every dot (.) indicates the levels of packages that you use in your project. Please check that com folder followed by the other folder names after every dot are present or not. I think this might help you. I answered your question based on my understanding (i.e, package issue which will be resolved by creating folders in your project. folders means packages). I am sorry if I gave you the wrong answer.
I need capture a video stream from my USB webcam, for this i use Opencv 2.4.6 for developing in Java. I follow the steps listed in here
I add the "C:\opencv\build\java\x64" dir to my System PATH and include the "opencv-246.jar" file into my libraries on ECLIPSE. When y run the explame
import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
public class Main {
public static void main(String[] args) {
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
Mat m = Mat.eye(3, 3, CvType.CV_8UC1);
System.out.println("m = " + m.dump());
}
}
i get
m = [1, 0, 0;
0, 1, 0;
0, 0, 1]
OK =)
but when i run
import org.opencv.highgui.VideoCapture;
public class Main {
public static void main(String[] args) {
VideoCapture vc = new VideoCapture(0);
if(vc.isOpened()){
System.out.println("Works!");
}
}
}
i get
Exception in thread "main" java.lang.UnsatisfiedLinkError: org.opencv.highgui.VideoCapture.n_VideoCapture(I)J
at org.opencv.highgui.VideoCapture.n_VideoCapture(Native Method)
at org.opencv.highgui.VideoCapture.<init>(VideoCapture.java:113)
at Main.main(Main.java:5)
i add all the routes containes in:
C:\opencv\build\x64\vc10
one by one,but doesn`t work.
Finally i create a variable called OPENCV_DIR with C:\opencv\build\x64\vc10 but still getting UnsatisfiedLinkError.
PLEASE HELP ME!
in your second example , you skipped this line
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
so the opencv libs werent loaded, UnsatisfiedLinkError, etc...
[edit]:
thanks to #Jishnu Prathap for highlighting the java.library path issue, if you run into problems setting that, you can still try to use an absolute path to the java wrapper so/dll/dylib like:
System.load("/path to/our/java_wrapper");
I had a similar error while using OpenCV with java.I did 2 things to resolve it.
static{ System.loadLibrary(Core.NATIVE_LIBRARY_NAME); }
I added the path to OpenCV dll or .so to javalibpath or path. which actually didnt work for some reason and i ended up putting the OpenCV dll in the system32 folder.
Try the below code
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import nu.pattern.OpenCV;
public class OpencvMain
{
public static void main( String[] args )
{
OpenCV.loadLocally();
Mat mat = Mat.eye( 3, 3, CvType.CV_8UC1 );
System.out.println( "mat = " + mat.dump() );
}
}
For general users using opencv3.x:
HighGUI module does not exist anymore in Java for opencv 3.0 and above.
import org.opencv.videoio.VideoCapture;
instead of
import org.opencv.highgui.VideoCapture;
videoio includes VideoCapture, VideoWriter.
Similarly:
imgcodecs includes imread/imwrite and friends
Example:
Highgui.imread(fileName)
-->
Imgcodecs.imread(fileName)
So, I was having this problem too and I did what you all suggested, it worked fine in my x64 windows, but in a x86 couldn't make it work.
At last I found a solution by changing:
VideoCapture capture = new VideoCapture(0);
for
VideoCapture capture = new VideoCapture();
capture.open("resources/vid.MP4");
I don't know why this worked but I hope it may help somebody with my same problem.
I tried a lot of tutorials online for the resolution, only one of them have helped me.
There are two steps that are different in this method,
Firstly, while importing the java project from Opencv SDK into the Android studio, make sure to uncheck all the checkboxes presented in the import dialog.
Secondly, make sure you import the OpenCV.mk file that is in the native/jdk of the SDK..
The System.loadLibrary() seems to return true after this, which was a huge relief for me as it took me several hours to figure this out
Here's the link to the tutorial that helped me
https://medium.com/#rdeep/android-opencv-integration-without-opencv-manager-c259ef14e73b
I have been trying to fix this problem for more then 3 hours. I have noticed that there are question with similar problem and i have tried everything but its still not working.
I think that the problem has something to do with JSoup JAR file.
Here is link to similar problem How to add Jsoup in my project?
I have tried to set up both Android and normal Java project and same error appears.
EDIT: Here is the code, just in case
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
public class Klasa {
public static void main(String[] args){
try{
String servisURL = "http://www.sczg.unizg.hr/student-servis/";
Document doc = Jsoup.connect(servisURL).get();
Elements jobNode = doc.select("div.jobBox");
System.console().writer().print(jobNode.get(0).text());
}catch(Exception e){
System.out.println(e.getMessage().toString());
}
}
}
EDIT2: I have solved the problem
Just change System.console().writer().print(jobNode.get(0).text());
to
System.out.print(jobNode.get(0).text());
If you are using Eclipse, then follow these steps,
Right click on your project.
Go to Properties -> Java Build Path
Click on the Source tab -> Add Folder button.
Add the source folder of your project.
In case you want to attach an external source like a jar, click on Link Source.
I installed the JavaCV/OpenCV libraries, and I'm having a problem with the basic example code.
According to several examples that I have looked at, this code should load an image:
IplImage image = cvLoadImage("C:\\img.jpg");
But, when I run that I get a "cannot find symbol" error.
Since this is my first time using it, I'm not sure if I messed the install up or not.
According to the newest JavaCV readme, I do have the correct version of OpenCV. I also have all the JavaCV jar files imported. As far as I can tell, I also have all the paths set correctly too.
Anyone know what the problem is?
Edit:
Full code:
import com.googlecode.javacv.CanvasFrame;
import com.googlecode.javacv.cpp.opencv_core.IplImage;
import java.io.File;
public class demo {
public static void main(String[] args)
{
IplImage image = cvLoadImage("C:\\img.jpg");
final CanvasFrame canvas = new CanvasFrame("Demo");
canvas.showImage(image);
canvas.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
}
}
Error when I try to run it:
Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: cvLoadImage
at javacv.demo.main(demo.java:17)
Java Result: 1
Seems like it is claiming cvLoadImage doesn't take a string as an argument.
A walk around that i find for you is to load the image by ImageIO and passe it later to IplImage
e.g.:
BufferedImage img = ImageIO.read(new File("C:\\img.jpg") );
IplImage origImg = IplImage.createFrom(img);
This solved my problem: import static org.bytedeco.javacpp.opencv_imgcodecs.*;
You have to add this import statement:
import static org.bytedeco.javacpp.opencv_imgcodecs.cvLoadImage;
This is required so that the static method cvLoadImage can be used without using the class name.
You have to import com.googlecode.javacv.cpp.opencv_highgui.*;
With javacv 0,9 you have to import static org.bytedeco.javacpp.opencv_highgui.*;
I got the same error then, i imported the following package, problem solved.
import static com.googlecode.javacv.cpp.opencv_highgui.*;
This might be old but for those who stumbled upon this problem like me just now,
here is how I solved it and why:
First OP's error: Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - Erroneous sym type: cvLoadImage at javacv.demo.main(demo.java:17)
This indicates that the compiler cannot find the cvLoadImage method that you are trying to call.
cvLoadImage is a static method under JavaCPP.
Specifically it is a static method under opencv_imgcodecs class.
To solve this issue one must first specify the import of the opencv_imgcodecs class.
This can be done by adding the import:
import static org.bytedeco.javacpp.opencv_imgcodecs.cvLoadImage;
This in turn would result for the opencv_imgcodecs class to be usable within your class along with its static methods and other functions.
I hope this helps.
Got the same problem recently.
if you are using javacv-0.10 (more recent at the moment), import manually this one:
import static org.bytedeco.javacpp.opencv_highgui.*;
but the source of JRE of the project should be higher than 1.5
In my case, the problem happened when the squeegee in debug mode.
Try to run in normal mode.