Removing FRAMES from the Camera FRAMES set

Removing FRAMES from the Camera FRAMES set

The FRAMES object of the CAMERA control has 2 different methods:
RemoveAt(int ImageNumberToRemove)
Remove(mySelectedFrameHandle)

I've tried both of those methods and I don't get any kind of error but the frames are never really removed.

My situation is that I'm allowing end user to capture multiple pictures
Then I use a slide control to show how many pictures are available
and there is a small image that shows "You are viewing 1 of 5 images"
for example. I can slide up and down with no problem and I always then
display the given image as:

Frame frame = oCam.Frames[(int)scrlBar1.Value - 1];

picImage.Image = frame.Image;

That all works great and I can grab as many images as the user wants to and display them all 1 at a time as they scroll.

But I also have the requirement to remove an image from the collection if the user should decide that they got trigger happy when pressing the camera button.

Any help with how to successfully remove an image from the FRAMES collection for the CAMERA object would be greatly appreciated.

Thanks in advance,
Dalton

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.


Hi Dalton,

It is important for you to realize that if the MCA you are running on has a PD with a lower version on it, that upgrading to SDK 2.1 will require the you to upgrade to a PD >= PD 2.1. So upgrading to use the DeleteImage call may not be in your best interest. In that case you should work with the local collection as described below.

The method Remove actually removes an item from the local collection object, this does not remove the Frame object from the MCA store. So the below code portions would give you the expected result, where ct2 will be less than ct1 by value 1, if at least one image was captured.

int ct1 = frames.Count;

if (ct1 > 0)

{

frames.Remove(ct1 - 1);

int ct2 = frames.Count;

}

But if you call oCam.Frames again, it will return the original count of images form the MCA store and populate the Frames object with that.

In SDK 2.1 onwards we have provided method named DeleteImage as part of Frames class. Please refer the descriptions of the overloaded methods from SDK .Net API documentations as below.

DeleteImage (HCHandleType)
Deletes either the specified frame, or all of the Frames within the current frames collection (both from the collection and MCA SDK store) depending on the parameter passed.

DeleteImage (Int32)
Deletes the Frame at given the index from the frames collection (both from the collection and MCA SDK store).

This above DeleteImage method removes the stored image(s) from the MCA store as well as from the collection and you might prefer to use this for your purpose. Please remember, once an image is deleted in this manner, there is no way to get back that image form the MCA store. Please check out these APIs and let us know if this resolves your problem.

John C

Quoting - daltonruer
The FRAMES object of the CAMERA control has 2 different methods:
RemoveAt(int ImageNumberToRemove)
Remove(mySelectedFrameHandle)

I've tried both of those methods and I don't get any kind of error but the frames are never really removed.

My situation is that I'm allowing end user to capture multiple pictures
Then I use a slide control to show how many pictures are available
and there is a small image that shows "You are viewing 1 of 5 images"
for example. I can slide up and down with no problem and I always then
display the given image as:

Frame frame = oCam.Frames[(int)scrlBar1.Value - 1];

picImage.Image = frame.Image;

That all works great and I can grab as many images as the user wants to and display them all 1 at a time as they scroll.

But I also have the requirement to remove an image from the collection if the user should decide that they got trigger happy when pressing the camera button.

Any help with how to successfully remove an image from the FRAMES collection for the CAMERA object would be greatly appreciated.

Thanks in advance,
Dalton

Steve,

Thank you for the excellent response. I'll create a local FRAMES object and pull the frames to it when they are snapped rather than going back to oCam.Frames all of the time. That will do the trick and explains why I got the results I was getting.

Do you have a link where I can upgrade to the PD for 2.1? I originally pulled the 2.1 SDK but all I could find for our C5's from Motion was the PD 2.0.1, so I had to back down my SDK as well.

Thanks again for the insight this will enable the functionality I need for sure,
Dalton

Login to leave a comment.