This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes Webcam & Threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Webcam & Threads" Watch "Webcam & Threads" New topic
Author

Webcam & Threads

Anand Karia
Ranch Hand

Joined: Sep 25, 2004
Posts: 156

Dear All

Touch Screen Time and Attendance Project overview:
==================================================
Operating System : Windows
IDE : Netbeans
Database : Postgres
Project Name : Time and Attendance
Webcamera : Creative Webcam

Coding Details
==============
Main form = barcodeScanning_1.java
Time class extended by Threads = myCurrentServerTime.java
Webcam class extended by Threads = t1.java with t2.java
other t2.java is used for webcam form and to set and get live picture from webcam.

When user start entering their token no then webcam starts processing. It take picture from a path and live picture from webcam and store into another path and at end report is generated with live picture.

Problem:
========
Wht problem i am facing is that i can not run both threads at one time. When i tries to run them using Thread.sleep(2000) method or boolean = true/false my CPU speed goes to 100% and webcam images doesnot appear on screen only black screen is coming and my form hangup due to continue processing.

So finally i stop one thread and run only webcam threads with the click of button. Means when user start touching token number my threads get start and when punch button is press then my threads stop and it get data from database and shown on form.

But problem is that when my thread runs CPU process goes to 100%. and delay of taking live pic from webcam comes out and employee starts getting late.

Here is my code for webcam threads, kindly suggest me where am i wrong and how can i reduce my CPU process and how can i get live picture without delaying.












Love is GOD and GOD is Love.
Anand Karia
IT Concretor.......
M/s. Anand Karia Concreting IT
Nicholas Jordan
Ranch Hand

Joined: Sep 17, 2006
Posts: 1282

What problem you are facing that cannot run both threads at one time probably comes from
//here boolean is checked for webcam processing.
where you do a while(true) in the constructor for t2.

How do to public class t2 extends Frame would be better questioned in
Swing / AWT / SWT / JFace

The reason CPU speed goes to 100% and webcam images does work is using using Thread.sleep(2000);//

Is this is the entire code from barcodeScanning_1.java that starts threads ? Thre may be something else in the code that is not right.
[ December 16, 2007: Message edited by: Nicholas Jordan ]

"The differential equations that describe dynamic interactions of power generators are similar to that of the gravitational interplay among celestial bodies, which is chaotic in nature."
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Webcam & Threads