-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Method getImage() return images referencing the same raster bytes #182
Comments
Hi @humber1000, This hack with unlocking webcam to open it in parallel may lead you to many problems, including Java crash, especially when the webcam is closed, and this method will work only on Windows (because of the bug in the videoinput library actually). On Linux or Mac OS you will simply get an error. Just wanted to explain this - opening single webcam in parallel is fundamentally wrong and you should avoid this. If you want more details I can explain you later because now I have to catch the last bus to my apartment or I will have to go 13 km by foot at night. In regards to the image replacement - I guess this may be caused by the fact you are using non-blocking mode where image is buffered (open method with arg true), but I have to verify this. Try opening webcam with open(false) and check again. Seems like the images are not really replaced, but by the fact that you are always getting the same image. Please correct me if I'm wrong. |
You are absolutely correct. The image instances are actually completely different objects, but the data beneath the raster references the same |
I uploaded newest JAR into Sonatype repo, you can download it from here: I already confirmed it's fixing problem you've found, but please confirm it as well. In regards to the problem with button... It's pretty weird since As for the parallel playing, I haven't said it's not possible - you can of course play image from one webcam in unlimited number of panels (as long as you have resources for that), but you cannot open it twice (the webcam device). This is because when you open camera, it allocates native instance which is using DirectShow on Windows, libv4l on Linux and QuickTime on Mac. The problem arose because Windows allows two separate instances to use the same camera device (Linux and Mac does not allow such operation) via the same capture graph, and when you close one instance, it will destroy capture graph, so when second instance will try to read it, it will most likely crash because of segmentation fault, or with some strange error in console (if you are lucky enough). Here is the small program I used to debug the problem (as you suggested). I moved it into examples: Thank you very much for finding this bug :) Take care! |
Thanks to you, for your great collaboration. |
sarxos... I'm sorry for bringing you bad news... but the new .jar works the same than the old one. The problem persists. |
The OpenIMAJGrabber.dll should not put it in any folder. It's automatically extracted by BridJ. Just replace RC6 JAR in the classpath with the new one and you should be fine. This is default driver, embedded in Webcam Capture JAR, which should work fine as it is, so it doe not require any specific instructions. When you say "it works the same", what do you actually mean? I used the simple example I prepared to test issue you've described (images replaced in vector) and confirmed it was there. After I fixed the bug, the same code confirmed it does not persist any more. Have you removed previous Webcam Capture JAR from classpath and replaced by new one, or you just added new one without removing previous? Also, are you using Maven? In such case, JAR replacement will not work since you have to change dependency in your POM if this is the case. |
Maven? I'm not using nothing with such a name, as far as I know. I'm only using your .jar files. |
I can help you with the code (just drop it somewhere or put on Github), but not with the configuration, since I'm completely unfamiliar with JCreator (I'm using Eclipse IDE). Maven is a dependency manager. In small projects dependencies managing problem does not usually exist, but when the project grows, you found that number of dependencies (JARs) you have to use use in code, constantly grows, and you realize in one moment that some classes are missing, some methods does not exits, etc - this is because of wrong or missing JARs included in classpath. Maven takes this burden from you and create dependency tree which contains all required JARs and download them from the Central Repository which contains more than half million of officially released files. It knowns what JARs are required by other JARs because their creators declared this when they put them in Maven Central. Learning Maven may be a little hard for the beginning, but after you are familiar with this tool, it's like a blessing in your everyday programming life. All my projects I created in several years back from now, are using Maven and I cannot imagine managing all required JARs manually. |
First, let me congratulate you for your work. Your Webcam Capture library is awesome! Very effective and much more easy to use than the JMF from sun-oracle. Secondly, forgive me for my bad english, if it is. It's not my native language.
Well, now... the issue... I'm making and application that shows the images of several webcams in a window (JFrame), and if you select one of them, it is shown in the main windows (a JFrame too). Everything was going well, the webcams was shown in the selection window, and the selected webcam was shown in the main window. But when I get to the moment of taking a picture (using the getImage() method) in the main window, the problem comes out. Every picture that I take is stored in a Vector, which is passed as the argument for a viewer window (JFame), and when I open it, it turns out that every image in the sequence of the viewer window is the same, the last one. It seems as if the last picture taken replaces the earlier ones in the vector.
But there's more. Whenever I clik a button in the viewer window, the webcam takes a snapshot and replaces the central image of the viewer panel (the bigger one) with the new one.
So we have two issues in here:
I would be very thankful if help me out with this. You'll see, this is part of my thesis, and if you take some time for helping out to solve this issues I would really appreciate it.
I'm going to show you the relevant parts of my code so you can understand the way I'm doing the things.
For detecting the several webcams connected I use the following code:
In the selection window, the several webcams are showing through a square that extends from JToggleButton. This is the constructor for the squares:
Now, once I do click over any square, the image appears immediately in the main window, with a bigger size. The main window implements the ActionListener interface, and this is the relevant part of the actionPerformed method:
Well, as I told you before, I would be very grateful if you help me solve this problems.
Thanks in advanced.
AH!... And my OS is Windows 7 (32-bit), and I'm usin webcam-capture-0.3.10-RC6-dist. My webcmas are Genius ISlim 300X.
The text was updated successfully, but these errors were encountered: