Acquire Images from webcam in LabVIEW 8.5

I've been working with Labview for week now and have done several
online tutorials and things like that. I need to be able to record an
image from a webcam into Labview. I've found numerous discussions on
the topic but none that contain any solid examples. I have Labview 8.5
with the NI-IMAQ drivers and NI Vision.
What
are the basic steps that need to be done to aquire an image from a
webcam and display it on a front panel? Any example VI's or detailed
descriptions would be more than welcome. Please understand that I have
just started working with LabView so some concepts like device drivers
are still a little new to me. Thank you for any help you can provide.

Hi CanadianKyle,
I've been working with Labview for few months now and have done several online tutorials and things like that.
but i can not tell you exactly that Vision requirement is must or not?......
But I Think there is no other way to use this without Vision 7.1 or Higher.
U will get Vision with evaluation version on Ni.com.
You can try for this, It will help you.
best luck.

Similar Messages

  • Acquire image from USB webcam

    Hey everyone.  I have a Logitech USB webcam that I would like to use to acquire still images.  I am using LV 8.2.  All the posts I have read suggest using NI-IMAQ for USB Cameras.  I have tried to install it, but it says "You must have Vision 7.1 or higher with LabVIEW 7.0 or higher, or you must have Vision Assistant 7.1 or higher installed to use this add-on."  I don't have Vision or Vision Assistant.  Am I doing something wrong?  None of the other posts seemed to mention that you needed Vision in order to use the add-on.  Does anyone know how I can acquire images from my USB webcam through LV 8.2 without having to buy additional software?  Thanks!
    Jay Mathews
    CPP, Inc.

    This question comes up often. That driver is something that NI provides as a convenience, and yes it requires additional software, as stated on the description for it. As for alternatives, did you get any software with the camera that looks like it could be used with LabVIEW, like an ActiveX library? That can certainly be used. As mentioned in this thread, supposedly RoboLab for LabVIEW has some tools, but I've never used it myself. You can also try the LabVIEW Webcam Library. Kind of old, though.

  • How do I acquire images from my usb webcam ?

    Hi all ,
    How do I acquire images from my usb webcam (logitech quickcam express ) ?
    I use Labview 7 .

    Pedrus wrote:
    > Hi all ,
    > How do I acquire images from my usb webcam (logitech quickcam express)?
    > I use Labview 7 .
    This seems a very popular question coming up about once every week at
    least. And there are many good answers in the developer Zone on www.ni.com
    Check out:
    Irene He's IVision Toolkit:
    http://www.hytekautomation.com/Products/IVision.html
    or
    Pete Parentes WebCam library:
    http://www.cs.unc.edu/~parente/labview/index.shtml
    The first is a rather impressive Video Manipulation library with a
    nice video capture interface to VfW too, and the second is a simple
    video capture library to access any VfW compliant device.
    Rolf K"
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How to Display a image from WebCam in the Forms 10.1.2.0.2!

    Hi Friends!
    I'm using a Forms 10.1.2.0.2 and i need to display of someway a image from webcam in some item inside the Forms!
    This is possible?
    I saw an explanation in http://www.orafaq.com/forum/t/89431/67467/ but it works only for a Forms 6.0!
    Somebody can Help me?

    As Jan mentioned, there is no way to display webcam video in Forms unless you create a Java Bean which can be incorporated into your form. As Pauli mentioned, if your webcam software is viewable via a browser, you can use WEB.SHOW_DOCUMENT to display a browser window with the content, however you will not be able to put this content in the form using the method.
    A good starting place would be Google. Look for a java bean or applet which can operate a web cam.
    http://www.google.com/search?q=java+applet+web+cam

  • Acquiring images from an Analog Camera using Arduino and LabVIEW

    Hi All,
    I posted this on the LabVIEW Arduino community but I am not sure it went through.
    Check out this project I have been working on for the last two weeks.
    It allows you to capture lowres/low bit depth images with arduino with LabVIEW (needs NI vision).
    Here is the link
    Feel free to use the code (it is all downloadable).

    Hello cagell
    I just wanted to exprees my thanks for sharing your awesome project with our community.  I am a huge analog video enthusiast myself.  All the best!
    Sincerely,
    Greg S.

  • How to acquire image from S-video camera

    Hi,
    I have a camera with S-video interface. I use a S-video to USB adaptor to acquire the images from my camera. Popular video editor/maker softwares, for example Windows Movie Maker, ULead VideoStudio, etc.. are able to display the video capture from my camera (using the same S-video to USB adaptor). Thus, I think the adaptor transferred the camera to an USB Directshow camera already? However I cannot grab images/video using Labview. I have installed IMAQdx, and I can use the same LabView VI to grab images/video from my USB camera.
    Is there any suggestion for my case?
    Thanks.

    Make sure you are using the right color channel, in most cases YYUV will not display.  Use RGB.  Also try changing the resolution settings.
    Machine Vision, Robotics, Embedded Systems, Surveillance
    www.movimed.com - Custom Imaging Solutions

  • Read image from excelsheet using labview

    i need to know how to read image from excel sheet using Labview...m not able to get the appropriate property to display the image stored in excel sheet.
    thank you

    you need to ask Microsoft to find out the property name/location under Microsoft Excel. 

  • Video image from webcam resizes

    I am trying to develop a online presentation application which has the webcam feature. I am using JMF for this purpose. I am creating this as an applet. The first time when the page loads and the user clicks the start button to start the video, the webcam starts and the video is displayed in a small area of the applet.
    The left side of the applet displays the images. When the user clicks the next button, the next image from the vector is displayed and the image label displays the image number as 2.
    The problem is that, if the user clicks next button , the video image from the webcam gets resized. It scales itself in the horizontal direction. I have no clue as to why is this happeneing. Is this something due to the layout problem or JMF ?
    Any help in this matter will be highly appreciated.
    Regards,
    Sharad

    I guess its because you are having a BorderLayout. If with a borderlayout, components added will strech both ways (horizontally and vertically) but you seem to say that the video image strechs only horizontally, maybe components added to NORTH or SOUTH of a borderlayout would do that.
    Anyhow, try to set the layout to FlowLayout

  • Capturing an image from webcam

    hi, i'm trying to capture a image from a webcam, but i don't have a clue of how to do this, could anyone help me with samples or books.
    thanks.

    hi
    so as i understood u want to access the USB and make whats called camera interaction i worked with my webcam and i generate a video stream and i'm working now to sample this video
    i found these class on the internet u have to make a littel changes like camera defention
    * File: DeviceInfo.java.java
    * created 24.07.2001 21:44:12 by David Fischer, [email protected]
    import java.awt.Dimension;
    import javax.media.*;
    import javax.media.control.*;
    import javax.media.format.*;
    import javax.media.protocol.*;
    public class DeviceInfo
         public static Format formatMatches (Format format, Format supported[] )
              if (supported == null)
                   return null;
              for (int i = 0;  i < supported.length;  i++)
                   if (supported.matches(format))
                        return supported[i];
              return null;
         public static boolean setFormat(DataSource dataSource, Format format)
              boolean formatApplied = false;
              FormatControl formatControls[] = null;
              formatControls = ((CaptureDevice) dataSource).getFormatControls();
              for (int x = 0; x < formatControls.length; x++)
                   if (formatControls[x] == null)
                        continue;
                   Format supportedFormats[] = formatControls[x].getSupportedFormats();
                   if (supportedFormats == null)
                        continue;
                   if (DeviceInfo.formatMatches(format, supportedFormats) != null)
                        formatControls[x].setFormat(format);
                        formatApplied = true;
              return formatApplied;
         public static boolean isVideo(Format format)
              return (format instanceof VideoFormat);
         public static boolean isAudio(Format format)
              return (format instanceof AudioFormat);
         public static String formatToString(Format format)
              if (isVideo(format))
                   return videoFormatToString((VideoFormat) format);
              if (isAudio(format))
                   return audioFormatToString((AudioFormat) format);
              return ("--- unknown media device format ---");
         public static String videoFormatToString(VideoFormat videoFormat)
              StringBuffer result = new StringBuffer();
              // add width x height (size)
              Dimension d = videoFormat.getSize();
              result.append("size=" + (int) d.getWidth() + "x" + (int) d.getHeight() + ", ");
              // try to add color depth
              if (videoFormat instanceof IndexedColorFormat)
                   IndexedColorFormat f = (IndexedColorFormat) videoFormat;
                   result.append("color depth=" + f.getMapSize() + ", ");
              // add encoding
              result.append("encoding=" + videoFormat.getEncoding() + ", ");
              // add max data length
              result.append("maxdatalength=" + videoFormat.getMaxDataLength() + "");
              return result.toString();
         public static String audioFormatToString(AudioFormat audioFormat)
              StringBuffer result = new StringBuffer();
              // short workaround
              result.append(audioFormat.toString().toLowerCase());
              return result.toString();
    the second class:
    * File: MyDataSinkListener.java
    * created 24.07.2001 21:41:47 by David Fischer, [email protected]
    * Decription: simple data sink listener, used to check for end of stream
    import javax.media.datasink.*;
    public class MyDataSinkListener implements DataSinkListener
         boolean endOfStream = false;
         public void dataSinkUpdate(DataSinkEvent event)
              if (event instanceof javax.media.datasink.EndOfStreamEvent)
                   endOfStream = true;
         public void waitEndOfStream(long checkTimeMs)
              while (! endOfStream)
                   Stdout.log("datasink: waiting for end of stream ...");
                   try { Thread.currentThread().sleep(checkTimeMs); } catch (InterruptedException ie) {}
              Stdout.log("datasink: ... end of stream reached.");
    * File: MyDataSinkListener.java
    * created 24.07.2001 21:41:47 by David Fischer, [email protected]
    * Decription: simple data sink listener, used to check for end of stream
    import javax.media.datasink.*;
    public class MyDataSinkListener implements DataSinkListener
         boolean endOfStream = false;
         public void dataSinkUpdate(DataSinkEvent event)
              if (event instanceof javax.media.datasink.EndOfStreamEvent)
                   endOfStream = true;
         public void waitEndOfStream(long checkTimeMs)
              while (! endOfStream)
                   Stdout.log("datasink: waiting for end of stream ...");
                   try { Thread.currentThread().sleep(checkTimeMs); } catch (InterruptedException ie) {}
              Stdout.log("datasink: ... end of stream reached.");
    }[i]the 3rd class:/******************************************************
    * File: Stdout.java.java
    * created 24.07.2001 21:44:46 by David Fischer, [email protected]
    * Description: utility class for standard output
    public class Stdout
         public static void log(String msg)
              System.out.println(msg);
         public static void logAndAbortException(Exception e)
              log("" + e);
              flush();
              System.exit(0);
         public static void logAndAbortError(Error e)
              log("" + e);
              flush();
              System.exit(0);
         public static void flush()
              System.out.flush();
    the 4rt is :
    * File: TestQuickCamPro.java
    * created 24.07.2001 21:40:13 by David Fischer, [email protected]
    * Description: this test program will capture the video and audio stream
    * from a Logitech QuickCam� Pro 3000 USB camera for 10 seconds and stores
    * it on a file, named "testcam.avi". You can use the microsoft windows
    * media player to display this file.
    * operating system: Windows 2000
    * required hardware:  Logitech QuickCam� Pro 3000
    * required software: jdk 1.3 or jdk1.4 plus jmf2.1.1 (www.javasoft.com)
    * source files: DeviceInfo.java, MyDataSinkListener.java,
    *               Stdout.java, TestQuickCamPro.java
    * You can just start this program with "java TestQuickCamPro"
    * hint: please make shure that you setup first the logitech camerea drives
    * and jmf2.1.1 correctly. "jmf.jar" must be part of your CLASSPATH.
    * useful links:
    * - http://java.sun.com/products/java-media/jmf/2.1.1/index.html
    * - http://java.sun.com/products/java-media/jmf/2.1.1/solutions/index.html
    * with some small modifications, this program will work with any USB camera.
    import java.io.*;
    import javax.media.*;
    import javax.media.control.*;
    import javax.media.datasink.*;
    import javax.media.format.*;
    import javax.media.protocol.*;
    public class TestQuickCamPro
         private static boolean                    debugDeviceList = false;
         private static String                    defaultVideoDeviceName = "vfw:Microsoft WDM Image Capture (Win32):0";
         private static String                    defaultAudioDeviceName = "DirectSoundCapture";
         private static String                    defaultVideoFormatString = "size=176x144, encoding=yuv, maxdatalength=38016";
         private static String                    defaultAudioFormatString = "linear, 16000.0 hz, 8-bit, mono, unsigned";
         private static CaptureDeviceInfo     captureVideoDevice = null;
         private static CaptureDeviceInfo     captureAudioDevice = null;
         private static VideoFormat               captureVideoFormat = null;
         private static AudioFormat               captureAudioFormat = null;
         public static void main(String args[])
              // get command line arguments
              for (int x = 0; x < args.length; x++)
                   // -dd = debug devices list -> display list of all media devices - and exit
                   if (args[x].toLowerCase().compareTo("-dd") == 0)
                        debugDeviceList = true;
              // get a list of all media devices, search default devices and formats, and print it out if args[x] = "-dd"
              Stdout.log("get list of all media devices ...");
              java.util.Vector deviceListVector = CaptureDeviceManager.getDeviceList(null);
              if (deviceListVector == null)
                   Stdout.log("... error: media device list vector is null, program aborted");
                   System.exit(0);
              if (deviceListVector.size() == 0)
                   Stdout.log("... error: media device list vector size is 0, program aborted");
                   System.exit(0);
              for (int x = 0; x < deviceListVector.size(); x++)
                   // display device name
                   CaptureDeviceInfo deviceInfo = (CaptureDeviceInfo) deviceListVector.elementAt(x);
                   String deviceInfoText = deviceInfo.getName();
                   if (debugDeviceList)
                        Stdout.log("device " + x + ": " + deviceInfoText);
                   // display device formats
                   Format deviceFormat[] = deviceInfo.getFormats();
                   for (int y = 0; y < deviceFormat.length; y++)
                        // serach for default video device
                        if (captureVideoDevice == null)
                             if (deviceFormat[y] instanceof VideoFormat)
                             if (deviceInfo.getName().indexOf(defaultVideoDeviceName) >= 0)
                             captureVideoDevice = deviceInfo;
                             Stdout.log(">>> capture video device = " + deviceInfo.getName());
                        // search for default video format
                        if (captureVideoDevice == deviceInfo)
                             if (captureVideoFormat == null)
                             if (DeviceInfo.formatToString(deviceFormat[y]).indexOf(defaultVideoFormatString) >= 0)
                             captureVideoFormat = (VideoFormat) deviceFormat[y];
                             Stdout.log(">>> capture video format = " + DeviceInfo.formatToString(deviceFormat[y]));
                        // serach for default audio device
                        if (captureAudioDevice == null)
                             if (deviceFormat[y] instanceof AudioFormat)
                             if (deviceInfo.getName().indexOf(defaultAudioDeviceName) >= 0)
                             captureAudioDevice = deviceInfo;
                             Stdout.log(">>> capture audio device = " + deviceInfo.getName());
                        // search for default audio format
                        if (captureAudioDevice == deviceInfo)
                             if (captureAudioFormat == null)
                             if (DeviceInfo.formatToString(deviceFormat[y]).indexOf(defaultAudioFormatString) >= 0)
                             captureAudioFormat = (AudioFormat) deviceFormat[y];
                             Stdout.log(">>> capture audio format = " + DeviceInfo.formatToString(deviceFormat[y]));
                        if (debugDeviceList)
                             Stdout.log(" - format: " +  DeviceInfo.formatToString(deviceFormat[y]));
              Stdout.log("... list completed.");
              // if args[x] = "-dd" terminate now
              if (debugDeviceList)
                   System.exit(0);
              // setup video data source
              MediaLocator videoMediaLocator = captureVideoDevice.getLocator();
              DataSource videoDataSource = null;
              try
                   videoDataSource = javax.media.Manager.createDataSource(videoMediaLocator);
              catch (IOException ie) { Stdout.logAndAbortException(ie); }
              catch (NoDataSourceException nse) { Stdout.logAndAbortException(nse); }
              if (! DeviceInfo.setFormat(videoDataSource, captureVideoFormat))
                   Stdout.log("Error: unable to set video format - program aborted");
                   System.exit(0);
              // setup audio data source
              MediaLocator audioMediaLocator = captureAudioDevice.getLocator();
              DataSource audioDataSource = null;
              try
                   audioDataSource = javax.media.Manager.createDataSource(audioMediaLocator);
              catch (IOException ie) { Stdout.logAndAbortException(ie); }
              catch (NoDataSourceException nse) { Stdout.logAndAbortException(nse); }
              if (! DeviceInfo.setFormat(audioDataSource, captureAudioFormat))
                   Stdout.log("Error: unable to set audio format - program aborted");
                   System.exit(0);
              // merge the two data sources
              DataSource mixedDataSource = null;
              try
                   DataSource dArray[] = new DataSource[2];
                   dArray[0] = videoDataSource;
                   dArray[1] = audioDataSource;
                   mixedDataSource = javax.media.Manager.createMergingDataSource(dArray);
              catch (IncompatibleSourceException ise) { Stdout.logAndAbortException(ise); }
              // create a new processor
              // setup output file format  ->> msvideo
              FileTypeDescriptor outputType = new FileTypeDescriptor(FileTypeDescriptor.MSVIDEO);
              // setup output video and audio data format
              Format outputFormat[] = new Format[2];
              outputFormat[0] = new VideoFormat(VideoFormat.INDEO50);
              outputFormat[1] = new AudioFormat(AudioFormat.GSM_MS /* LINEAR */);
              // create processor
              ProcessorModel processorModel = new ProcessorModel(mixedDataSource, outputFormat, outputType);
              Processor processor = null;
              try
                   processor = Manager.createRealizedProcessor(processorModel);
              catch (IOException e) { Stdout.logAndAbortException(e); }
              catch (NoProcessorException e) { Stdout.logAndAbortException(e); }
              catch (CannotRealizeException e) { Stdout.logAndAbortException(e); }
              // get the output of the processor
              DataSource source = processor.getDataOutput();
              // create a File protocol MediaLocator with the location
              // of the file to which bits are to be written
              MediaLocator dest = new MediaLocator("file:testcam.avi");
              // create a datasink to do the file
              DataSink dataSink = null;
              MyDataSinkListener dataSinkListener = null;
              try
                   dataSink = Manager.createDataSink(source, dest);
                   dataSinkListener = new MyDataSinkListener();
                   dataSink.addDataSinkListener(dataSinkListener);
                   dataSink.open();
              catch (IOException e) { Stdout.logAndAbortException(e); }
              catch (NoDataSinkException e) { Stdout.logAndAbortException(e); }
              catch (SecurityException e) { Stdout.logAndAbortException(e); }
              // now start the datasink and processor
              try
                   dataSink.start();
              catch (IOException e) { Stdout.logAndAbortException(e); }
              processor.start();
              Stdout.log("starting capturing ...");
              try { Thread.currentThread().sleep(10000); } catch (InterruptedException ie) {}     // capture for 10 seconds
              Stdout.log("... capturing done");
              // stop and close the processor when done capturing...
              // close the datasink when EndOfStream event is received...
              processor.stop();
              processor.close();
              dataSinkListener.waitEndOfStream(10);
              dataSink.close();
              Stdout.log("[all done]");
    }finally search with the athour name there is an additional program u must download to detect ur cam .
    i hope that is work with u

  • Capturing image from Webcam

    Hi,
    Is there any way in which Java can be used to capture images from the webcam and save it to a predefined image file name?
    Any examples out there?
    Alternatively, I could have the application written in other languages, but still, I would need my main Java app to launch this external app.
    Thanks alot.

    Hi,
    Is there any way in which Java can be used to capture
    images from the webcam and save it to a predefined
    image file name?
    Any examples out there?
    Alternatively, I could have the application written in
    other languages, but still, I would need my main Java
    app to launch this external app.
    Thanks alot.Yes, the ExampleSave from the JavaTwain package at http://www.gnome.sk does this job :)
    If you just want to see how Java Twain works with your webcam (works with a scanner too):
    - java (1.2 or higher for Windows, 1.3 or higher for Mac OS X) has to be installed on your computer
    - a scanner or camera has to be installed on your computer
    - download the trial package from http://www.gnome.sk
    - unzipp it
    - go to the examples directory of the unzipped package
    - in Windows: doubleclick the runExampleShow.bat
    - in MacOS:
        - open the Terminal window
        - change the working directory to the examples
        - run .sh file (type ExampleShow.sh or sh ExampleShow.sh)
    This will pop up the Twain Source Selection user interface. There, all your scanners and cameras which do have a twain driver should be listed. (About 90% of scanners and cameras on the market do have a twain driver for Windows, only a few do have a twain driver for MacOS.) Select one of them. The user interface of the selected scanner (camera) will appear. Confirm the scanning (you can set the scanning parameters first). The scanned image will be displayed in a separate window. To end the application, close that window.
    Running different examples, you can test scanning with hidden UI, saving the scanned image, using ADF, ...
    If there is any problem, do not hesitate to inquire about it at the technical support, email: [email protected] . I am the member of the staff :)
    Erika Kupkova

  • Can load image from file using LabVIEW and display on IMAQ graph?

    I dont have IMAQ Vision for LabVIEW on my computer. Is it possible to load image file and display on an IMAQ graph?
    Thanks!

    Hey werwr,
    In response to: "I dont have IMAQ Vision for LabVIEW on my computer. Is it possible to load image file and display on an IMAQ graph?"
    As of right now, in order to read an image from file, you actually do need the IMAQ Vision software. The IMAQ driver without the Vision VI's will allow you to collect images from a framegrabber, and it will allow you to save those images to file. But the function that allows you to read an image from file does require the Vision VI's. Once you have the VI to read images from a file, you will be able to display the image on an IMAQ "Graph" or otherwise known as an Image Display.
    I hope this helps. Please let me know if you have any further questions.
    Thanks,
    DJ
    Applications Engineer
    National Instruments

  • Errors in code that captures images from webcam

    Here is the code
    import javax.swing.*;
    import javax.swing.border.*;
    import java.io.*;
    import javax.media.*;
    import javax.media.datasink.*;
    import javax.media.format.*;
    import javax.media.protocol.*;
    import javax.media.util.*;
    import javax.media.control.*;
    import java.util.*;
    import java.awt.*;
    import java.awt.image.*;
    import java.awt.event.*;
    import com.sun.image.codec.jpeg.*;
    // import com.sun.media.vfw.VFWCapture; // JMF 2.1.1c version
    import com.sun.media.protocol.vfw.VFWCapture; // JMF 2.1.1e version
    public class JWebCam extends JFrame
    implements WindowListener, ComponentListener
    protected final static int MIN_WIDTH = 320;
    protected final static int MIN_HEIGHT = 240;
    protected static int shotCounter = 1;
    protected JLabel statusBar = null;
    protected JPanel visualContainer = null;
    protected Component visualComponent = null;
    protected JToolBar toolbar = null;
    protected MyToolBarAction formatButton = null;
    protected MyToolBarAction captureButton = null;
    protected Player player = null;
    protected CaptureDeviceInfo webCamDeviceInfo = null;
    protected MediaLocator ml = null;
    protected Dimension imageSize = null;
    protected FormatControl formatControl = null;
    protected VideoFormat currentFormat = null;
    protected Format[] videoFormats = null;
    protected MyVideoFormat[] myFormatList = null;
    protected boolean initialised = false;
    * Constructor
    public JWebCam ( String frameTitle )
    super ( frameTitle );
    try
    UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
    catch ( Exception cnfe )
    System.out.println ("Note : Cannot load look and feel settings");
    setSize ( 320, 260 ); // default size...
    addWindowListener ( this );
    addComponentListener ( this );
    getContentPane().setLayout ( new BorderLayout() );
    visualContainer = new JPanel();
    visualContainer.setLayout ( new BorderLayout() );
    getContentPane().add ( visualContainer, BorderLayout.CENTER );
    statusBar = new JLabel ("");
    statusBar.setBorder ( new EtchedBorder() );
    getContentPane().add ( statusBar, BorderLayout.SOUTH );
    * Initialise
    * @returns true if web cam is detected
    public boolean initialise ( )
    throws Exception
    return ( initialise ( autoDetect() ) );
    * Initialise
    * @params _deviceInfo, specific web cam device if not autodetected
    * @returns true if web cam is detected
    public boolean initialise ( CaptureDeviceInfo _deviceInfo )
    throws Exception
    statusBar.setText ( "Initialising...");
    webCamDeviceInfo = _deviceInfo;
    if ( webCamDeviceInfo != null )
    statusBar.setText ( "Connecting to : " + webCamDeviceInfo.getName() );
    try
    setUpToolBar();
    getContentPane().add ( toolbar, BorderLayout.NORTH );
    ml = webCamDeviceInfo.getLocator();
    if ( ml != null )
    player = Manager.createRealizedPlayer ( ml );
    if ( player != null )
    player.start();
    formatControl = (FormatControl)player.getControl ( "javax.media.control.FormatControl" );
    videoFormats = webCamDeviceInfo.getFormats();
    visualComponent = player.getVisualComponent();
    if ( visualComponent != null )
    visualContainer.add ( visualComponent, BorderLayout.CENTER );
    myFormatList = new MyVideoFormat[videoFormats.length];
    for ( int i=0; i<videoFormats.length; i++ )
    myFormatList = new MyVideoFormat ( (VideoFormat)videoFormats );
    Format currFormat = formatControl.getFormat();
    if ( currFormat instanceof VideoFormat )
    currentFormat = (VideoFormat)currFormat;
    imageSize = currentFormat.getSize();
    visualContainer.setPreferredSize ( imageSize );
    setSize ( imageSize.width, imageSize.height + statusBar.getHeight() + toolbar.getHeight() );
    else
    System.err.println ("Error : Cannot get current video format");
    invalidate();
    pack();
    return ( true );
    else
    System.err.println ("Error : Could not get visual component");
    return ( false );
    else
    System.err.println ("Error : Cannot create player");
    statusBar.setText ( "Cannot create player" );
    return ( false );
    else
    System.err.println ("Error : No MediaLocator for " + webCamDeviceInfo.getName() );
    statusBar.setText ( "No Media Locator for : " + webCamDeviceInfo.getName() );
    return ( false );
    catch ( IOException ioEx )
    statusBar.setText ( "Connecting to : " + webCamDeviceInfo.getName() );
    return ( false );
    catch ( NoPlayerException npex )
    statusBar.setText ("Cannot create player");
    return ( false );
    catch ( CannotRealizeException nre )
    statusBar.setText ( "Cannot realize player");
    return ( false );
    else
    return ( false );
    * Dynamically create menu items
    * @returns the device info object if found, null otherwise
    public void setFormat ( VideoFormat selectedFormat )
    if ( formatControl != null )
    player.stop();
    imageSize = selectedFormat.getSize();
    formatControl.setFormat ( selectedFormat );
    player.start();
    statusBar.setText ( "Format : " + selectedFormat );
    currentFormat = selectedFormat;
    visualContainer.setPreferredSize ( currentFormat.getSize() );
    setSize ( imageSize.width, imageSize.height + statusBar.getHeight() + toolbar.getHeight() );
    else
    System.out.println ("Visual component not an instance of FormatControl");
    statusBar.setText ( "Visual component cannot change format" );
    public VideoFormat getFormat ( )
    return ( currentFormat );
    protected void setUpToolBar ( )
    toolbar = new JToolBar();
    // Note : If you supply the 16 x 16 bitmaps then you can replace
    // the commented line in the MyToolBarAction constructor
    formatButton = new MyToolBarAction ( "Resolution", "BtnFormat.jpg" );
    captureButton = new MyToolBarAction ( "Capture", "BtnCapture.jpg" );
    toolbar.add ( formatButton );
    toolbar.add ( captureButton );
    getContentPane().add ( toolbar, BorderLayout.NORTH );
    protected void toolbarHandler ( MyToolBarAction actionBtn )
    if ( actionBtn == formatButton )
    Object selected = JOptionPane.showInputDialog (this,
    "Select Video format",
    "Capture format selection",
    JOptionPane.INFORMATION_MESSAGE,
    null, // Icon icon,
    myFormatList, // videoFormats,
    currentFormat );
    if ( selected != null )
    setFormat ( ((MyVideoFormat)selected).format );
    else if ( actionBtn == captureButton )
    Image photo = grabFrameImage ( );
    if ( photo != null )
    MySnapshot snapshot = new MySnapshot ( photo, new Dimension ( imageSize ) );
    else
    System.err.println ("Error : Could not grab frame");
    * autoDetects the first web camera in the system
    * searches for video for windows ( vfw ) capture devices
    * @returns the device info object if found, null otherwise
    public CaptureDeviceInfo autoDetect ( )
    Vector list = CaptureDeviceManager.getDeviceList ( null );
    CaptureDeviceInfo devInfo = null;
    if ( list != null )
    String name;
    for ( int i=0; i<list.size(); i++ )
    devInfo = (CaptureDeviceInfo)list.elementAt ( i );
    name = devInfo.getName();
    if ( name.startsWith ("vfw:") )
    break;
    if ( devInfo != null && devInfo.getName().startsWith("vfw:") )
    return ( devInfo );
    else
    for ( int i = 0; i < 10; i++ )
    try
    name = VFWCapture.capGetDriverDescriptionName ( i );
    if (name != null && name.length() > 1)
    devInfo = com.sun.media.protocol.vfw.VFWSourceStream.autoDetect ( i );
    if ( devInfo != null )
    return ( devInfo );
    catch ( Exception ioEx )
    // ignore errors detecting device
    statusBar.setText ( "AutoDetect failed : " + ioEx.getMessage() );
    return ( null );
    else
    return ( null );
    * deviceInfo
    * @note outputs text information
    public void deviceInfo ( )
    if ( webCamDeviceInfo != null )
    Format[] formats = webCamDeviceInfo.getFormats();
    if ( ( formats != null ) && ( formats.length > 0 ) )
    for ( int i=0; i<formats.length; i++ )
    Format[] aFormat = formats;
    if ( aFormat[i] instanceof VideoFormat )
    Dimension dim = ((VideoFormat)aFormat).getSize();
    // System.out.println ("Video Format " + i + " : " + formats.getEncoding() + ", " + dim.width + " x " + dim.height );
    else
    System.out.println ("Error : No web cam detected");
    * grabs a frame's buffer from the web cam / device
    * @returns A frames buffer
    public Buffer grabFrameBuffer ( )
    if ( player != null )
    FrameGrabbingControl fgc = (FrameGrabbingControl)player.getControl ( "javax.media.control.FrameGrabbingControl" );
    if ( fgc != null )
    return ( fgc.grabFrame() );
    else
    System.err.println ("Error : FrameGrabbingControl is null");
    return ( null );
    else
    System.err.println ("Error : Player is null");
    return ( null );
    * grabs a frame's buffer, as an image, from the web cam / device
    * @returns A frames buffer as an image
    public Image grabFrameImage ( )
    Buffer buffer = grabFrameBuffer();
    if ( buffer != null )
    // Convert it to an image
    BufferToImage btoi = new BufferToImage ( (VideoFormat)buffer.getFormat() );
    if ( btoi != null )
    Image image = btoi.createImage ( buffer );
    if ( image != null )
    return ( image );
    else
    System.err.println ("Error : BufferToImage cannot convert buffer");
    return ( null );
    else
    System.err.println ("Error : cannot create BufferToImage instance");
    return ( null );
    else
    System.out.println ("Error : Buffer grabbed is null");
    return ( null );
    * Closes and cleans up the player
    public void playerClose ( )
    if ( player != null )
    player.close();
    player.deallocate();
    player = null;
    public void windowClosing ( WindowEvent e )
    playerClose();
    System.exit ( 1 );
    public void componentResized ( ComponentEvent e )
    Dimension dim = getSize();
    boolean mustResize = false;
    if ( dim.width < MIN_WIDTH )
    dim.width = MIN_WIDTH;
    mustResize = true;
    if ( dim.height < MIN_HEIGHT )
    dim.height = MIN_HEIGHT;
    mustResize = true;
    if ( mustResize )
    setSize ( dim );
    public void windowActivated ( WindowEvent e ) { }
    public void windowClosed ( WindowEvent e ) { }
    public void windowDeactivated ( WindowEvent e ) { }
    public void windowDeiconified ( WindowEvent e ) { }
    public void windowIconified ( WindowEvent e ) { }
    public void windowOpened ( WindowEvent e ) { }
    public void componentHidden(ComponentEvent e) { }
    public void componentMoved(ComponentEvent e) { }
    public void componentShown(ComponentEvent e) { }
    protected void finalize ( ) throws Throwable
    playerClose();
    super.finalize();
    class MyToolBarAction extends AbstractAction
    public MyToolBarAction ( String name, String imagefile )
    // Note : Use version this if you supply your own toolbar icons
    // super ( name, new ImageIcon ( imagefile ) );
    super ( name );
    public void actionPerformed ( ActionEvent event )
    toolbarHandler ( this );
    class MyVideoFormat
    public VideoFormat format;
    public MyVideoFormat ( VideoFormat _format )
    format = _format;
    public String toString ( )
    Dimension dim = format.getSize();
    return ( format.getEncoding() + " [ " + dim.width + " x " + dim.height + " ]" );
    class MySnapshot extends JFrame
    protected Image photo = null;
    protected int shotNumber;
    public MySnapshot ( Image grabbedFrame, Dimension imageSize )
    super ( );
    shotNumber = shotCounter++;
    setTitle ( "Photo" + shotNumber );
    photo = grabbedFrame;
    setDefaultCloseOperation ( WindowConstants.DISPOSE_ON_CLOSE );
    int imageHeight = photo.getWidth ( this );
    int imageWidth = photo.getHeight ( this );
    setSize ( imageSize.width, imageSize.height );
    final FileDialog saveDialog = new FileDialog ( this, "Save JPEG", FileDialog.SAVE );
    final JFrame thisCopy = this;
    saveDialog.setFile ( "Photo" + shotNumber );
    addWindowListener ( new WindowAdapter()
    public void windowClosing ( WindowEvent e )
    saveDialog.show();
    String filename = saveDialog.getFile();
    if ( filename != null )
    if ( saveJPEG ( filename ) )
    JOptionPane.showMessageDialog ( thisCopy, "Saved " + filename );
    setVisible ( false );
    dispose();
    else
    JOptionPane.showMessageDialog ( thisCopy, "Error saving " + filename );
    else
    setVisible ( false );
    dispose();
    setVisible ( true );
    public void paint ( Graphics g )
    g.drawImage ( photo, 0, 0, getWidth(), getHeight(), this );
    * Saves an image as a JPEG
    * @params the image to save
    * @params the filename to save the image as
    public boolean saveJPEG ( String filename )
    boolean saved = false;
    BufferedImage bi = new BufferedImage ( photo.getWidth(null),
    photo.getHeight(null),
    BufferedImage.TYPE_INT_RGB );
    Graphics2D g2 = bi.createGraphics();
    g2.drawImage ( photo, null, null );
    FileOutputStream out = null;
    try
    out = new FileOutputStream ( filename );
    JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder ( out );
    JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam ( bi );
    param.setQuality ( 1.0f, false ); // 100% high quality setting, no compression
    encoder.setJPEGEncodeParam ( param );
    encoder.encode ( bi );
    out.close();
    saved = true;
    catch ( Exception ex )
    System.out.println ("Error saving JPEG : " + ex.getMessage() );
    return ( saved );
    } // of MySnapshot
    public static void main (String[] args )
    try
    JWebCam myWebCam = new JWebCam ( "TimeSlice Web Cam Capture" );
    myWebCam.setVisible ( true );
    if ( !myWebCam.initialise() )
    System.out.println ("Web Cam not detected / initialised");
    catch ( Exception ex )
    ex.printStackTrace();
    when I run it I get the following errors
    BufferToImage cannot convert buffer
    could not grab frame
    pls help

    Do you expect anyone to read this?
    http://forum.java.sun.com/help.jspa?sec=formatting
    By the way, you have a condition that makes it print those messages. Check why that condiiton isn't rue.

  • Elements freezing on acquire image from scanner

    When using a Neat NM-1000 scanner and I acqire image from scanner the program loads the Neat software to scan the image and runs the photo through the scanner and then freezes the software and will not allow me to continue. Is there and update I need or some settings I should make somewhere in the software?

    Thanks for your response.
    Can you please try scanning once outside of Oragnizer and import the scanned image manually in EO?
    Thanks
    Andaleeb

  • What software do i need to acquire image from a camera and 1407 board

    I need to acquire an image and measure thickness of a needle. I have labview 6.0.2 and have installed NI-IMAQ 2.5.1. What other software do i need to install? Do i need Advanced IMAQ Vision?

    With NI-IMAQ (now up to version 2.6) you are able to acquire, display, and save images. With IMAQ Vision, you'll be able to very accurately measure the thickness of the needle. If you attach an image to this post, I should be able to tell you just how accurate IMAQ Vison can be. You can find out more about IMAQ Vision (which is a component of the Vision Development Module for LabVIEW) here, http://sine.ni.com/apps/we/nioc.vp?cid=2881〈=US
    The other route (aka, the free one) is to convert the image into a 2D array of pixel values. From this array, you may be able to measure the thickness of the needed by writing your own algorithm. It most likely won't be as precise as the IMAQ Vision tools (which give you real world measurements down to the 0.1 pixels).
    The Vision Development Module will work with LabVIEW 6i, so there is no requirement to upgrade to LabVIEW 7 Express. But in case you're curious, the new LabVIEW is really something. www.ni.com/labview is the place for more info.
    Kyle V.

  • Simply capture raster image from webcam or camera

    Hello everybody!
    First, thanks to all for all the good ideas I've read on this forum!
    I would like to capture images (raster type) from an external device (webcam, camera...) to apply particular processing on them. I would not like to lose time extracting these rasters... in a way to focus on my postprocessing stage. Does anybody know the simplest way to do this? JMStudio? but how?
    Thanks a lot!!!

    Hi...
    Could you not just use the Java Media Framework API to do an image capture from the webcam?
    http://java.sun.com/dev/evangcentral/totallytech/jmf.html

Maybe you are looking for