I'm trying to learn OpenCV 3.2.0 with Java and I am having trouble loading in a video file into the program. I work on Eclipse in Windows 10. This is a snippet from the code:
Mat frame = new Mat();
Mat frameHSV = new Mat();
VideoCapture vcap = new VideoCapture("C:\\Users\\UserName\\Downloads\\video.mov");
while(vcap.read(frame))
{
frameHSV = ColorBase.BGRToHSV(frame);
displayWindow.updateFrame(frameHSV);
}
When I launch this program, I only get a white window with nothing in it. I think this has something to do with this being on windows, as I tried it out on a Linux computer and it worked as intended. This means the path points to the correct location and that the code actually works.
Is this an issue with OpenCV and Paths on windows? I get no complile errors, only a white window. How is this fixed?
I managed to solve it by following another thread on this site that I didn't find before:
OpenCV Java binds VideoCapture from file failing silently
I followed the second answer on this thread and it worked perfectly after that.
Its either a video codec, or permission issue, can you move the file to other drive like: D:\\video.mov and try?
Related
I have developed a Play framework application on my windows PC and then transferred it onto my Linux box, I'm uploading a video and a photo to the server, this upload process works perfectly on my Windows PC, but doesn't work on the Linux box.
code I'm using in windows:
String root = Play.application().path().toString();
String globalFolderPath = root + "/public/globalUploadFolder/";
File globalFolder = new File(globalFolderPath);
Code I tried in Linux as well as the above code:
String globalFolderPath = "../../public/globalUploadFolder/";
File globalFolder = new File(globalFolderPath);
Is there a something I have to do regarding file paths differently on the Linux box, could it be a permission issue?
I'm lost as to why this is happening.
The problem was solved by using File.separator
From the camera direct streaming is possible and can display it as well, but not write to a video file any format will do. But from rtsp we get frames by frames and i would like to develop without any more external librarys apart from opencv or javacv if possible.
and in opencv-java videoWriter is missing(here) so unable to capture video to a file.
In javacv was unable to create a stream or a recorder from rtsp.
case:
FrameGrabber grabber = new FFmpegFrameGrabber("rtsp://1ink...");
FrameRecorder fr = new FFmpegFrameRecorder("rtsp://linkf", 0);
Error is :
java.lang.UnsatisfiedLinkError: no jniavcodec in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1119)
at org.bytedeco.javacpp.Loader.loadLibrary(Loader.java:535)
at org.bytedeco.javacpp.Loader.load(Loader.java:410)
at org.bytedeco.javacpp.Loader.load(Loader.java:353)
at org.bytedeco.javacpp.avcodec.(avcodec.java:12)
at org.bytedeco.javacv.FFmpegFrameGrabber.(FFmpegFrameGrabber.java:103)
in both case
The rtsp link is working as i get photos from the camera.
Thanks in advance.
Found the issue. If any one will be helpfull with it.
In javacv if any one has the following error
java.lang.UnsatisfiedLinkError: no jniavcodec in java.library.path
do add
Class.forName("org.bytedeco.javacpp.swresample");
Rest will work fine. All the best.
I'm having to do some bits with reading in an image on Mac OSX, however it seems to hang when calling ImageIO.read ( File ). No stack trace seems to appear either, it literally just hangs. Was wondering if anyone else had experienced this problem?
I've been successful in writing an image, just seems to be a problem with reading. Working with .png files.
OSX 10.9.2
Java 1.7.40
The solution I found in the end was to do the following on the mac
File scrFile = ((TakesScreenshot)seleniumCommonHandler.getCurrentSeleniumDriver())
.getScreenshotAs(OutputType.FILE);
BufferedImage img = ImageIO.read( scrFile );
For some reason the ImageIO no matter what I tried could not read the image directly from the file system. By using this approach I managed to get around the issue.
I'm trying to set up JRI with Eclipse on a Windows 7 x64 system. I tried it once on my Laptop and it worked. Now on my Desktop it fails although everything of the R, rJava and JRI installation is exactly the same.
I set the JRI and R Paths correctly to:
C:\Program Files\R\R-2.15.1\library\rJava\jri;C:\Program Files\R\R-2.15.1\bin\x64
Also I set R_DOC_DIR etc in Eclipse.
Every time I try to run new Rengine(...); it fails without any error or exception. Debugging revealed an: <terminated, exit value: 10>C:\Program Files\Java\jre6\bin\javaw.exe (01.10.2012 18:00:31)
Is there anything I can try? It really bothers me that it works an my Laptop but not on my Workstation despite the same settings everywhere.
Edit: The code that is used to get the Rengine object.
public static Rengine getRengine(){
if (re == null) createRengine();
return re;
}
public static void createRengine(){
if (re!=null) return;
try{
if (!Rengine.versionCheck()) {
System.err.println("** Version mismatch **");
System.exit(1);
}
String[] arguments = {"--save"};
re=new Rengine(arguments, false, null);
if (!re.waitForR()) {
System.out.println("Cannot load R");
return;
}
}
catch (Exception e){
e.printStackTrace();
}
}
Edit: The last time i tried it i got an errormessage (creating of the REngine worked, this happened never before), R was missing a registryentry. After installing R 2.15.1 again it suddenly worked. Now after a restart it's the same like before. The program crashes at the creation of the REngine.
I was having the exact same problem. It turns out I had unchecked the box that asks to make a registry entry with the R version number. Once I let the installer run with that box checked, it seemed to work.
I would make sure your regedit looks like this:
Next up: getting this working in a portable way...
I am using R 3.2.2 and eclipse Mars on Windows 10 x64.
I faced the described issue today and tried around a bit. Finally, I found the root cause in the build path. Please check whether the following conditions are fulfilled:
1.) The following Java libraries from the JIRI folder on your hard disk shall be included as (user) libraries:
JIRI.jar
REngine.jar
JRIEngine.jar
2.) The native library jiri.dll is located in the subfolder "i386" for x86, whereas for x64 it is available in the subfolder "x64". The relevant one shall be added as separate native library location to the Java Build Path of the eclipse project. Otherwise, the file may not be considered as it is not located in the main JIRI folder.
Best regards
Philipp
I became so much upset with this simple code segment:
FileConnection fc = (FileConnection) Connector.open("file:///root1/photos/2.png");
System.out.println(is.available());
byte[] fileBytes = new byte[is.available()];
int sizef = is.read(fileBytes);
System.out.println("filesize:"+sizef);
When I deploy this midlet in my mobile (with proper file location) It works properly i.e it shows proper filesize, but in the pc emulator it is constantly giving filesize of: 0. Obviously no Exception and I have the proper file in that location.
I am using j2mewtk sdk in netbeans 6.9. I tried uninstalling, installing wtk & netbeans.
Another thing is Everytime I run the emulator it creates C:\Users\Mahsruf\j2mewtk\2.5.2\appdb\temp.DefaultColorPhone6 new location like temp.DefaultColorPhone1,2,3,4 etc.
If I use jme SDK 3.0 in netbeans the file size is still 0, but now with a extra line in output window: [WARN] [rms ] javacall_file_open: _wopen failed for: C:\Users\Mahsruf\javame-sdk\3.0\work\0\appdb\_delete_notify.dat
What am I doing wrong?
This is not coding related issue. If multiple instances of the same emulator skin run simultaneously, the toolkit generates unique file paths for each one. For example, on Windows instances of DefaultColorPhone might have a file path name of workdir\appdb\temp.DefaultColorPhone1, workdir\appdb\temp.DefaultColorPhone2, and so forth.
Solution: The file workdir\appdb\DefaultColorPhone\in.use keeps track of the number of storage roots marked as in use. If the emulator crashes, you need to delete the in.use file