This week's book giveaways are in the AI and JavaScript forums.
We're giving away four copies each of GANs in Action and WebAssembly in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of GANs in ActionE this week in the AI forum
or WebAssembly in Action in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
  • Knute Snortum
Sheriffs:
  • Liutauras Vilda
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Joe Ess
  • salvin francis
  • fred rosenberger

Using webcam-camera library for switch on my web cam

 
Ranch Hand
Posts: 1400
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have add the webcam-capture-0.3.10.jar in my project and add this piece of code:



Any idea, please?
Regards, Isaac
 
Marshal
Posts: 67340
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you imported it?
 
Angus Ferguson
Ranch Hand
Posts: 1400
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mean the jar or the project?

I copy /paste from here

And added the jar
 
Marshal
Posts: 67392
257
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't import .jars and you don't import projects. You add .jars to your CLASSPATH and you import classes from those .jars.
 
Angus Ferguson
Ranch Hand
Posts: 1400
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just created a new class and added the copy logic and added the jars
 
Rancher
Posts: 4450
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Isaac Ferguson wrote:I just created a new class and added the copy logic and added the jars



Added the jars to what?

How are you compiling this?
 
Angus Ferguson
Ranch Hand
Posts: 1400
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To the libreries in Netbeans
 
Bear Bibeault
Marshal
Posts: 67340
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are there import statements in your class?
 
Angus Ferguson
Ranch Hand
Posts: 1400
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes and it compiles
 
Bear Bibeault
Marshal
Posts: 67340
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then what is the error and when do you get it? Don't tell us; show us.
 
Angus Ferguson
Ranch Hand
Posts: 1400
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This one when debuging over "Webcam.getDefault() "

Webcam webcam = Webcam.getDefault(); //Here I get this error Unknown type "com.github.sarxos.webcam.Webcam"

 
Saloon Keeper
Posts: 2932
373
Android Eclipse IDE Angular Framework MySQL Database TypeScript Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you post the entire source file (including the import statements) it would be easier to help.
 
Bear Bibeault
Marshal
Posts: 67340
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Don't tell us; show us.



Telling us about the error is useless. Show us the error. Use code tags to preserve its formatting.
 
Bear Bibeault
Marshal
Posts: 67340
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And if its just a warning in an IDE you are talking about, it's not an error. Is there a real error?
 
Angus Ferguson
Ranch Hand
Posts: 1400
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok now it is working the class is this:(There was a conflict with jars)



 
Angus Ferguson
Ranch Hand
Posts: 1400
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi again,

I uploaded the war generated to a Tomcat remote hosting and it works for the index.jsp but when I submit the data via a button I get this error:


Any idea, please?
 
Dave Tolls
Rancher
Posts: 4450
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That looks to me like you are attempting to access the web cams on a remote server.
I suspect there aren't any.
 
Angus Ferguson
Ranch Hand
Posts: 1400
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
haha...yes maybe...what I am trying is to access the web cam of the computer which brose to the app

This is all the code in the Servlet

 
Dave Tolls
Rancher
Posts: 4450
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And the servlet runs on the server.
In the case of your remote Tomcat that's a long way away presumably.

It would work when run locally on your PC (assuming it has a web cam), but not on the remote.
 
Angus Ferguson
Ranch Hand
Posts: 1400
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any proposal for make it works remotely?
 
Dave Tolls
Rancher
Posts: 4450
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What exactly are you trying to do?
If you want to use the camera on the client machine and load the video onto the server then you would need something that actually runs on the client and streams the video to the server.
As I say, the code you are using seems (and it's a bit of guesswork based on that message) to be designed to run on the machine that actually has the camera.

Maybe Googling around for how to stream from a client web cam to a server?

This well outside my field, though...
 
Angus Ferguson
Ranch Hand
Posts: 1400
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have defined a little bit more how I would like to make it works.

First case: I would like to have an independent camera (I can just buy it), and place it in a point in the middle of the nowhere, then using my own mobile or desktop application from home make a pic and download it from the server.

Second case: I would like to have an URL which shows a view with a button, then the webcam makes a pic and show it in the view. The whole thing happens in the application server.

I am trying to put all the pieces together, for example, I just could use GlassFish as a server application and from my screen/view press a button and switch it on /off the camera via a java method.

I have found when searching online this resource VLCJ for streaming from the server to the client. But I get confused when having the app in a remote server which has GlassFish installed and the whole thing happens in the server but the webcam is in the local machine. How the local web cam access the remote server?

Any idea, please?





 
Marshal
Posts: 24937
61
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, putting a camera in the middle of nowhere is a well-known phenomenon, for example Mount St. Helens VolcanoCams. And in that page you'll notice that it says

VolcanoCam wrote:New camera images update to the server every three minutes.



So yeah, the camera is indeed connected to a server. But you seem to be interpreting "server" as something like Glassfish, whereas in real life all the webcam server needs to do is to sit there and take a photo every three minutes and store the photo on the server's hard drive. Actually that's not quite all, it does need to respond to requests for the latest photo, but all you need for that is a basic HTTP server.
 
Angus Ferguson
Ranch Hand
Posts: 1400
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then it should works with a camera which has wireless 3G connection, and can listen to a request from a remote application which is located in a remote Tomcat server. Isnt it?

Is there a similar project like the Mount St. Helens VolcanoCams?

Regards, Isaac
 
Angus Ferguson
Ranch Hand
Posts: 1400
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From a .jsp I call a Servlet with (a repeat it) this code:


It works well and it makes the pic but the camera doesnt switch off and I need to restart Tomcat to make another one.

Could I add some code at the end of the Servlet to switch off the camera?

 
Dave Tolls
Rancher
Posts: 4450
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a close() method?

You seem to have "opened" the camera, which I assume turns it on, so maybe there's a close?

What is CameraFunctions?

I found the sarxos git hub code, but don't see that class.
 
Angus Ferguson
Ranch Hand
Posts: 1400
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It works like this:



 
Paul Clapham
Marshal
Posts: 24937
61
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Isaac Ferguson wrote:Then it should works with a camera which has wireless 3G connection, and can listen to a request from a remote application which is located in a remote Tomcat server. Isnt it?



Yes, although the webcam server shouldn't care what's sending the request. Or are you expecting the camera itself to respond to requests? Chances are that the requester is going to be far away and not in the same wireless network as the camera.

Is there a similar project like the Mount St. Helens VolcanoCams?



There are probably millions of webcams around the world. There are webcams which show highway conditions, waterholes in Africa, geysers, and you name it. It's a well-established technology which you seem to be trying to reinvent.
 
Angus Ferguson
Ranch Hand
Posts: 1400
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It is a test I am doing for once the user press the button and the pic is made it is send you a generic Facebook page which contains all the pics.

In my local it works and the pic is saved before be sent (I still havent implemented the method to send it to FB), but when the code is in a remote server and the user access to the pressing button page, how to say the remote Tomcat "go to the user webcam and make a pic". This is the current status but later it will go further and instead of trigger the user laptop camera it will trigger an external fix camera.

I have found this : webCam, they talk about using an Ivideon Server but I want to use Tomcat and Servlets for this:

Any idea, please?
 
Paul Clapham
Marshal
Posts: 24937
61
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm still not clear on your design. So you've got a computer somewhere with a camera attached to it -- that much I'm pretty sure of. And you want this computer to run Tomcat -- you said that. But what requests is this Tomcat app supposed to be handling, and what response is it supposed to send for each request?
 
Angus Ferguson
Ranch Hand
Posts: 1400
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For testing I will use my laptop.

My laptop has internet connection and a browser.

I have a paid server which contains Tomcat. The web app is there not in my laptop.

The working is like this:

From my laptop I call the web app in the remote server using an URL like this: www.remotecam.org.

In the view of the app there is a button I press it and then the remote app, activates the local webCam of my laptop and makes me a pic.

Thats the way it works.

Technically, the button is in a .jsp, send a request to the Servlet, this makes a pic and stores it.

At the moment it works well locally and makes the pic, but my question is: How I make that the web app in remote activates the webcam of my laptop?

Any idea, please?
 
Paul Clapham
Marshal
Posts: 24937
61
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your setup works when the web app and the webcam are in the same network, but not when they are in different networks, then your code to access the webcam needs to be changed so it can work across networks. That's about all I can say about that since I don't know how your web app is accessing the camera.

But you still haven't said what the final setup is supposed to look like. You only described your testing setup, which is clearly flawed because it doesn't match the design of the desired system. Let's start again with a description of that system.
 
Dave Tolls
Rancher
Posts: 4450
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you say it works locally, what is "locally"?
Both the server and browser running on the same laptop?

I'm still trying to grasp how the remote server knows to take control of your webcam on the laptop...
 
Angus Ferguson
Ranch Hand
Posts: 1400
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats the question, how the remote camera connect with the webcam. There is anything in local. Only the web cam of the user.
 
Paul Clapham
Marshal
Posts: 24937
61
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Isaac Ferguson wrote:There is anything in local. Only the web cam of the user.



I'm translating this to say "There is nothing locally except the web cam".

If that's right, then you have to read the documentation of the camera to find out (a) how to connect it as a host on the network you want it to serve -- which is likely the whole internet -- and (b) how to configure it to respond to requests over that network.

It's quite likely that for most cameras the answer to step (a) is "You can't do that", in which case your design would be impractical and you would have to come up with another design.
 
Angus Ferguson
Ranch Hand
Posts: 1400
3
Netbeans IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. Then ,the most appropriate should be use only one kind of camera with bluetooth, which sends the pic to a dispositive with internet or a camera with internet itself which sends the pic to the server via 3G, isnt it?

So made it generic to automatically connect the most popular web cams when the user log in from the server looks far away...isnt it?
 
Did you ever grow anything in the garden of your mind? - Fred Rogers. Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!