Results 1 to 1 of 1
Thread: Problem in OpenCV code.
- 04-08-2010, 05:11 AM #1
Member
- Join Date
- Feb 2010
- Posts
- 15
- Rep Power
- 0
Problem in OpenCV code.
I had successfully compile my java code in Eclipse with name FaceDetection.java... I am getting an Exception in thread "main" java.lang.NoSuchMethodError: main.... Please help me to remove this Exception.. Here is the code....
Java Code:import java.awt.*; import java.awt.event.*; import java.awt.image.MemoryImageSource; import hypermedia.video.OpenCV; @SuppressWarnings("serial") public class FaceDetection extends Frame implements Runnable { /** * Main method. * @param String[] a list of user's arguments passed from the console to this program */ public static void main( String[] args ) { System.out.println( "\nOpenCV face detection sample\n" ); new FaceDetection(); } // program execution frame rate (millisecond) final int FRAME_RATE = 1000/30; OpenCV cv = null; // OpenCV Object Thread t = null; // the sample thread // the input video stream image Image frame = null; // list of all face detected area Rectangle[] squares = new Rectangle[0]; /** * Setup Frame and Object(s). */ FaceDetection() { super( "Face Detection Sample" ); // OpenCV setup cv = new OpenCV(); cv.capture( 320, 240 ); cv.cascade( OpenCV.CASCADE_FRONTALFACE_ALT ); // frame setup this.setBounds( 100, 100, cv.width, cv.height ); this.setBackground( Color.BLACK ); this.setVisible( true ); this.addKeyListener( new KeyAdapter() { public void keyReleased( KeyEvent e ) { if ( e.getKeyCode()==KeyEvent.VK_ESCAPE ) { // ESC : release OpenCV resources cv.dispose(); System.exit(0); } } } ); // start running program t = new Thread( this ); t.start(); } /** * Draw video frame and each detected faces area. */ public void paint( Graphics g ) { // draw image g.drawImage( frame, 0, 0, null ); // draw squares g.setColor( Color.RED ); for( Rectangle rect : squares ) g.drawRect( rect.x, rect.y, rect.width, rect.height ); } /** * Execute this sample. */ @SuppressWarnings("static-access") public void run() { while( t!=null && cv!=null ) { try { t.sleep( FRAME_RATE ); // grab image from video stream cv.read(); // create a new image from cv pixels data MemoryImageSource mis = new MemoryImageSource( cv.width, cv.height, cv.pixels(), 0, cv.width ); frame = createImage( mis ); // detect faces squares = cv.detect( 1.2f, 2, OpenCV.HAAR_DO_CANNY_PRUNING, 20, 20 ); // of course, repaint repaint(); } catch( InterruptedException e ) {;} } } }
Similar Threads
-
problem in my code
By wannabe in forum New To JavaReplies: 5Last Post: 04-12-2010, 04:38 AM -
Problem my code..
By Miyaki in forum New To JavaReplies: 3Last Post: 03-09-2009, 12:36 AM -
Help me!!!!!!!! Problem with Code!!
By Miyaki in forum New To JavaReplies: 0Last Post: 03-08-2009, 12:26 AM -
Problem with code
By oregon in forum New To JavaReplies: 3Last Post: 08-05-2007, 05:57 PM -
Problem with zero in my code
By fernando in forum New To JavaReplies: 1Last Post: 08-05-2007, 06:39 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks