Page 1 of 2 1 2 LastLast
Results 1 to 15 of 16

Thread: Windows Presentation Foundation (WPF) and IC control - Compatible?

  1. #1
    Join Date
    Jun 2011
    Posts
    6

    Windows Presentation Foundation (WPF) and IC control - Compatible?

    Hello,

    We have been developing our Visual Basic application using the new Windows Presentation Foundation (WPF) layer ontop of VB.NET. (http://msdn.microsoft.com/en-us/library/ms754130.aspx)

    I was wondering if IC Imaging control's .NET libraries will be functional with this, or will we have to migrate back to "only" VB.NET

    Does anyone have experience with IC+WPF? I cannot foresee any reason why it would not work, but there is some slight GUI changes in the WPF system.

    Thank you

  2. #2
    Join Date
    Jan 2003
    Location
    Bremen, Germany
    Posts
    4,898

    Re: Windows Presentation Foundation (WPF) and IC control - Compatible?

    Hello,

    you can use the WindowsFormsHost in order to use IC in WPF.
    Best regards
    Stefan
    IC Imaging Control Support

  3. #3
    Join Date
    Jun 2011
    Posts
    6

    Re: Windows Presentation Foundation (WPF) and IC control - Compatible?

    Hello,

    Do you think you could be more specific? The simple act of adding a reference to the IC 3.2 causes any WPF program to cease compiling.

    Thank you,
    M. Adham

  4. #4
    Join Date
    Jan 2003
    Location
    Bremen, Germany
    Posts
    4,898

    Re: Windows Presentation Foundation (WPF) and IC control - Compatible?

    Hello,

    In WPF there is a special container for non WPF controls.

    Add an instance of IC Imaging Control to your window class:
    Code:
    TIS.Imaging.ICImagingControl icImagingControl1 = new TIS.Imaging.ICImagingControl("Insert your
    license key here");
    On the WPF designer, insert a WindowsFormsHost element at the area where you want the live
    display.
    (In XAML, this is <WindowsFormsHost Name="windowsFormsHost1"/> ).

    In the Window_Loaded event handler, set
    Code:
    windowsFormsHost1.Child = icImagingControl1;
    You now have IC Imaging Control visible and ready to work in the WPF application.

    Please note, IC 3.2 has no license key anymore.
    Best regards
    Stefan
    IC Imaging Control Support

  5. #5
    Join Date
    Jun 2011
    Posts
    6

    Re: Windows Presentation Foundation (WPF) and IC control - Compatible?

    Thank you for your reply. We manage to root-cause the issue to the fact that VB2010 was using an old DLL for TIS.imaging. For anyone working with WPF + .net on VB2010, here is the correct procedure to get it going:

    1. Create new WPF project
    2. add the following references:
      -System.Windows.Forms
      - WindowsFormsIntegration
    3. Go to add references
      - Browse: C:\Program Files\Common Files\IC Imaging Control 3.2\bin\v4.0.30319\x86\TIS.Imaging.ICImagingContro l32.dll
      *** For some reason, VB2010 with WPF only picked up the older DLL (v2.0.50727) in the default .net references. This will not work.
    4. Code:


    XAML

    Code:
    <Window x:Class="MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
        <Grid>
            <WindowsFormsHost Name="windowsFormsHost1"/>
        </Grid>
    </Window>
    Class:

    Code:
    Class MainWindow
        Friend WithEvents icImagingControl1 As TIS.Imaging.ICImagingControl
    
        Private Sub Window_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
            windowsFormsHost1.Child = icImagingControl1
            icImagingControl1 = New TIS.Imaging.ICImagingControl
        End Sub
    End Class

  6. #6
    Join Date
    Jan 2003
    Location
    Bremen, Germany
    Posts
    4,898

    Re: Windows Presentation Foundation (WPF) and IC control - Compatible?

    Hi,

    Thank you for posting the correct way. I only want to suggest
    Code:
    Class MainWindow
        Friend WithEvents icImagingControl1 As TIS.Imaging.ICImagingControl
    
        Private Sub Window_Loaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Loaded
            icImagingControl1 = New TIS.Imaging.ICImagingControl
            windowsFormsHost1.Child = icImagingControl1 ' Lines exchanged
        End Sub
    End Class
    Best regards
    Stefan
    IC Imaging Control Support

  7. #7
    Join Date
    Jun 2011
    Posts
    6

    Re: Windows Presentation Foundation (WPF) and IC control - Compatible?

    Thank you Stefan. One last question, we are always getting an Unhandled exception when exiting our WPF application when using the IC reference. Is there a disconnect or clean-up method that needs to be handled before application closing?

    Thank you,
    M. Adham

  8. #8
    Join Date
    Jan 2003
    Location
    Bremen, Germany
    Posts
    4,898

    Re: Windows Presentation Foundation (WPF) and IC control - Compatible?

    Hello,

    I am not sure about this unhandled exception. But I suggest to stop the live video and close the device (.Device="") before deleting the IC Imaging Control instance.
    Best regards
    Stefan
    IC Imaging Control Support

  9. #9
    Join Date
    Jun 2011
    Posts
    6

    Re: Windows Presentation Foundation (WPF) and IC control - Compatible?

    In case anyone is looking for an easy way to display an image from an IC stream using WPF, it is not as straightforward as it is using a normal VB form:

    Code:
    Dim hBitmap As IntPtr
    Dim destination As BitmapSource
    Dim sizeOptions As BitmapSizeOptions = BitmapSizeOptions.FromEmptyOptions()
    icImagingControl1.MemorySnapImage()
    hBitmap = icImagingControl1.ImageActiveBuffer.Bitmap.GetHbitmap()
    destination = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, sizeOptions)
    destination.Freeze()
    img.Source = destination
    and you can define the image in XAML:
    Code:
    <Image Name="img" />
    Not sure if this is the most efficient method, but it was the only way I could get it to work.

    Cheers,
    Moe

  10. #10
    Join Date
    Jun 2011
    Posts
    6

    Re: Windows Presentation Foundation (WPF) and IC control - Compatible?

    In Case anyone else is using WPF, to ensure you do not have a Null Exeption error when closing your application, make sure that in the "closed" routine, you set your WindowsFormHost.Child = null. This was an error that took us some months to solve.

    Example:
    private void Closed(System.Object sender, System.EventArgs e)
    {
    icImagingControl1.LiveStop();
    icImagingControl2.LiveStop();
    icImagingControl1.Device = "";
    icImagingControl2.Device = "";
    icImagingControl1.Dispose();
    icImagingControl2.Dispose();

    fromHost.Child = null;
    fromHost2.Child = null;
    }

  11. #11
    Join Date
    Jan 2003
    Location
    Bremen, Germany
    Posts
    4,898

    Re: Windows Presentation Foundation (WPF) and IC control - Compatible?

    Hello,

    Thank you very much for posting your solution. I really appreciate this.
    Best regards
    Stefan
    IC Imaging Control Support

  12. #12
    Join Date
    Aug 2012
    Posts
    3

    Re: Windows Presentation Foundation (WPF) and IC control - Compatible?

    The information in this thread has been very useful and I have managed to display the output from from an ImagingSource DFK 31AU 03 camera.

    I have discovered though that I can only display using the YUY2 video format at 7.5FPS and below, or the Y800 format at 30FPS, but not the BY8 format at any frame rate. When the program fails it closes apparently without any exception or device lost event.

    The none of the CPU cores are taxed and your DemoApp can run BY8 at 30FPS and the YUY2 up to 7.5FPS, so it appears that the USB2 is not the limitation. Ditto the VB_Dialog_Template run in debug under VB2010.

    I've attached the .xaml and .xaml.vb files as text but I'm new to this forum, so I don't know whether you'll see them.

    Can you suggest how I might improve this code?
    Attached Files Attached Files

  13. #13
    Join Date
    Jan 2003
    Location
    Bremen, Germany
    Posts
    4,898

    Re: Windows Presentation Foundation (WPF) and IC control - Compatible?

    Hi

    I have a suspect only: It may happen, that your image buffer does not get unlocked, because the wait in the frameTick() using 50 ms is longer than the frame rate's time interval of 33 ms at 30 fps. I would expect all buffers being locked at one point of time. Then more or or less randomly one buffer is unlocked, because your time calls the ShowImagebuffer() function, which unlocks an image buffer, so you can receive the next buffer. If there is only one image buffer usable, then the frame rate of the image display is only the half frame rate or less.

    If you send me the complete project in a zip file, I will try to correct it.
    Best regards
    Stefan
    IC Imaging Control Support

  14. #14
    Join Date
    Aug 2012
    Posts
    3

    Re: Windows Presentation Foundation (WPF) and IC control - Compatible?

    Thanks Stefan,

    Attached is the complete project as used in my previous post. You will note that it references the TIS...dll located in the Debug directory to avoid the problem indicated by Moe_adham.

    For your possible interest, we plan to display the outputs from two of these cameras on a single screen for a Science Museum exhibit that demonstrates the use of the Tan function in calculation of range. If you ever visit Questacon in Canberra, Australia, you may get to see the fruits of our combined effort.

    For this application the frame rate is not too critical but reliability is. Any thing you can do to improve my code will be greatly appreciated and given the fantastic performance of these cameras, we are likely to use them in future exhibits.

    Regards

    Robert Parker
    Attached Files Attached Files

  15. #15
    Join Date
    Aug 2012
    Posts
    3

    Re: Windows Presentation Foundation (WPF) and IC control - Compatible?

    As with most video streams, wpf will not overlay the camera video using xaml.

    I tried quickly to see if I could grab images and use those (as I have previously done using the AForge library) but the documentation seemed to suggest that this was a poor alternative to using the IC imaging control overlay system.

    Following the examples in the IC Imaging Control .NET Component User's Guide, I've got this working but I did have to make one change to the ShowBitmap function in order for a valid Graphics object to be found.

    The attached file has the code which has been dropped into the vb solution attached to my previous post. The argument supplied to the ShowBitmap function would not generate a suitable Graphic object, so using the example in the GetGraphics help, I have used the icImagingControl1.OverlayBitmap object directly with positive results.

    Do you have any insight on what has happened here?

    Regards

    Robert Parker
    Attached Files Attached Files

Page 1 of 2 1 2 LastLast

Similar Threads

  1. IC Imaging Control under Windows 7
    By sanger64 in forum IC Imaging Control .NET
    Replies: 2
    Last Post: March 9, 2011, 16:26:01
  2. IC labview, 64-bit compatible?
    By Ari in forum IC Imaging Control ActiveX
    Replies: 3
    Last Post: November 17, 2010, 14:34:40
  3. Is IC Imaging Control 3.0 workable in VS 2005 in Windows vista Home premium system?
    By Linda Xu in forum IC Imaging Control C++ Class Library
    Replies: 3
    Last Post: December 15, 2008, 09:25:52
  4. Compatible with Osprey & Winnov?
    By Unregistered in forum MontiVision Development Kit
    Replies: 1
    Last Post: January 3, 2005, 20:19:04
  5. Compatible USB digital cameras
    By Unregistered in forum IC Imaging Control ActiveX
    Replies: 0
    Last Post: November 1, 2003, 20:53:45

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •