locked
Image capture Windows Mobile 5.0 without CameraCaptureDialog RRS feed

  • Question

  • Hello everybody! I'm a beginner in programming on Windows Mobile. My program should make an image, so we have to do image capture. I tried to use CameraCaptureDialog but the method ShowDialog doesn't work. Maybe someone know how I can make image capture without using CameraCaptureDialog? I also try to find something about DirectShow but I can't find good example of using DirectShow for creating image capture on Windows Mobile 5.0. I'l be very glad for your help! Thanks a lot!!!!

    I'm using C#.

    Monday, March 22, 2010 5:02 PM

Answers

  • Hi,

     

    I don't have a full C# sample for you but I had to play around with DirectShow recently. Once you have it inialized and displaying on screen its easy enoguh to then capture the image. Theres decent enough samples and the necessary DLLs here: http://alexmogurenko.com/blog/directshownetcf/

     

    This snippet in VB.NET can create an instance of the camera and display it on screen.

     

     

    Dim ds As DirectShowNETCF.Camera.Camera
    
    Private Sub InitCamera()
            Try
                ds = New DirectShowNETCF.Camera.Camera
    
                ds.CapType = Camera.CaptureType.PreviewStill
                ds.autoFocusOn()
                ds.setMediaType(1)
                ds.init()
             
    
                ds.run(Me.Panel1.Handle)
                Refresh()
                Application.DoEvents()
    
            Catch ex As Exception
            
            End Try
     End Sub

     

    Steve

    Monday, March 22, 2010 5:17 PM
  • Hi Jt1k,

    Firstly, CameraCaptureDialog can work, I am not sure something wrong with your code, please refer to MSDN document and try the sample code:
    http://msdn.microsoft.com/en-us/library/microsoft.windowsmobile.forms.cameracapturedialog.showdialog.aspx

     

    Secondly, if you know c++, SDK also provide native code to capture image with image, path:
    C:\Program Files\Windows Mobile 6 SDK\Samples\PocketPC\CPP\win32\CameraCapture

     

    Best regards,
    Guang-Min Bian - MSFT


    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    Wednesday, March 24, 2010 3:55 AM

All replies

  • Hi,

     

    I don't have a full C# sample for you but I had to play around with DirectShow recently. Once you have it inialized and displaying on screen its easy enoguh to then capture the image. Theres decent enough samples and the necessary DLLs here: http://alexmogurenko.com/blog/directshownetcf/

     

    This snippet in VB.NET can create an instance of the camera and display it on screen.

     

     

    Dim ds As DirectShowNETCF.Camera.Camera
    
    Private Sub InitCamera()
            Try
                ds = New DirectShowNETCF.Camera.Camera
    
                ds.CapType = Camera.CaptureType.PreviewStill
                ds.autoFocusOn()
                ds.setMediaType(1)
                ds.init()
             
    
                ds.run(Me.Panel1.Handle)
                Refresh()
                Application.DoEvents()
    
            Catch ex As Exception
            
            End Try
     End Sub

     

    Steve

    Monday, March 22, 2010 5:17 PM
  • Thanks! I download this library and see some examples there, write my own program and try to test it on my smartphone. And I have some mistakes:

    Didn't find the name of file or assembly "DirectShowNETCF, Version=1.9.0.0, Culture=neutral, PublicKeyToken=null" or one of their
    dependences.

    All right but the examples from this library didn't work either(on smart phone and emulator), are they working when you using them? What's wrong? I add the library using add reference and type in my code using DirectShowNETCF. On my smart phone I copy only exe file, maybe I have to copy the library as well and write the path to it? Thanks for your help!!!

    This is my code:

    DirectShowNETCF.Camera.Camera myCam = new DirectShowNETCF.Camera.Camera();
    List<string> resolutions = myCam.getMediaTypes();
    myCam.CapType = DirectShowNETCF.Camera.CaptureType.Still;
    // myCam.setMediaType(resolutionCombo.SelectedIndex);
    myCam.init();
    myCam.run();
    myCam.stillImage(@"\My pictures\test.jpg");
    myCam.stop();
    myCam.release();
    Tuesday, March 23, 2010 1:01 PM
  • Hi Jt1k,

    Firstly, CameraCaptureDialog can work, I am not sure something wrong with your code, please refer to MSDN document and try the sample code:
    http://msdn.microsoft.com/en-us/library/microsoft.windowsmobile.forms.cameracapturedialog.showdialog.aspx

     

    Secondly, if you know c++, SDK also provide native code to capture image with image, path:
    C:\Program Files\Windows Mobile 6 SDK\Samples\PocketPC\CPP\win32\CameraCapture

     

    Best regards,
    Guang-Min Bian - MSFT


    Please remember to mark the replies as answers if they help and unmark them if they provide no help
    Wednesday, March 24, 2010 3:55 AM