• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Webcam & Threads

 
Anand Karia
Ranch Hand
Posts: 156
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.










 
Nicholas Jordan
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic