MiaoRong / javacv

Automatically exported from code.google.com/p/javacv
GNU General Public License v2.0
0 stars 0 forks source link

Problem with hypermedia.video.OpenCV; #192

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Jvavcv is working fine with the sample code(Smoother.java)
2. I was searching found this code for face recognition but its not 
working(code given below)

==========================================================================
import java.awt.*;
import java.awt.event.*;
import java.awt.image.MemoryImageSource;

import hypermedia.video.OpenCV;

public class FaceDetection extends Frame implements Runnable {

    // 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.
     */
    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 ) {;}
        }
    }

    /**
     * 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();
    } 

}
==========================================================================

What is the expected output? What do you see instead?
It should work fine.

What version of the product are you using? On what operating system?
I am using net Beans, opencv superpack , windows 7.Everything is working fine 
but the hypermedia package is not found.

Please provide any additional information below.
Thanks a lot.

Original issue reported on code.google.com by i.vishal...@gmail.com on 24 Apr 2012 at 7:43

GoogleCodeExporter commented 9 years ago
I'm sorry, but I don't see where you are using JavaCV in the code you posted 
above... ?

Original comment by samuel.a...@gmail.com on 24 Apr 2012 at 1:37

GoogleCodeExporter commented 9 years ago
Thanks for a quick reply.
I am new to opencv as well as javacv, so please forgive me for asking such 
question.

Now what I am saying is I got his code on opencv website.These are clearly 
written in java.what I am saying is how to use javacv to run this program.What 
package in javacv contains the hypermedia package of opencv?
thanks in advance.

Original comment by i.vishal...@gmail.com on 24 Apr 2012 at 5:04

GoogleCodeExporter commented 9 years ago
JavaCV doesn't contain that package. You could try the Demo class in the 
README.txt file if you're interested in getting face detection working with 
JavaCV though.

But please, post your questions on the mailing list if possible, thank you.

Original comment by samuel.a...@gmail.com on 26 Apr 2012 at 5:02