Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

ImageViewer.Attach

Hi All,

 

I have a Windows Form application that has an ImageViewer control. I make use of the Attach method of the ImageViewer to attach a VisionImage. It is my understanding that I need to call the Attach method once in the beginning and modify the contents of the VisionImage (when I am grabbing images I call ImaqSession.Grab and pass the vision image that is attached to the ImageViewer). However, the camera from which I am grabbing images is in one machine and the Windows Form application is another machine. So, I serialize the VisionImage object from the machine that the camera is connected and pass it on to the machine that has the windows form using some transport mechanism. So, at the Windows Form end, I have a copy of VisionImage that is in the camera end. However, I need to modify the contents of the VisionImage that is attached to the ImageViewer. Now, what I do is the following

 

ImageViewer.Image.Dispose()

ImageViewer.Attach(newImage)

 

which is essentially to Dispose the old image attached and attach a new image. Can you please let me know whether there is any other better way to handle this because I see that the images being updated slowly in ImageViewer. Perhaps, do something like ImageViewer.Image.Copy(newImage)? (I know there is no equivalent of Copy in VisionImage but is there any other equivalent)

 

Thanks,

 

Venkat

0 Kudos
Message 1 of 5
(3,801 Views)

Hi Venkat,

 

What transport mechanism are you using to get the image from one computer to another?  Is it through serial since you mention that you serialize the data.  If you are passing data this way, serial is a slower protocol than say TCP/IP and could be why the images update so slowly.

Cole R.
National Instruments
Software Engineer
0 Kudos
Message 2 of 5
(3,778 Views)

Hi Cole,

 

Thank you for your time and reply. I am using two modes transport. If the Windows Form application and camera are in different process spaces (can be in the same machine but can also be in different machines), we use DSSP which internally uses TCP. However, if the Windows Form application and camera are in the same process space, we simply deep clone(serialize the VisionImage using BinaryFormatter and deserialize it to get a copy of the VisionImage). We have to yet look at the image transfer rate. As you right said, it could be a problem but we think that it is highly unlikely.

 

However, we would still like to know whether Dipsoing the image in the ImageViewer and attaching the new image every time we get a new image will have a performance hit. If it does have a performance problem, is there any way by which I can update the contents without me having to Dispose the old image and attach the new image.

 

Thanks,

 

Venkat

0 Kudos
Message 3 of 5
(3,774 Views)

Hi All,

 

I was wondering if anyone had an opportunity to look at this.

 

Thanks,

 

Venkat

0 Kudos
Message 4 of 5
(3,716 Views)

Hi Venkat,

 

Have you had the opportunity to benchmark how much time this actually takes for you?  I would worry that if you do not dispose of each image that you would develop a memory leak.  

Cole R.
National Instruments
Software Engineer
0 Kudos
Message 5 of 5
(3,689 Views)