1
votes

Hi all, I have a problem that I believe will end up a minor syntax problem. I hope. I am pulling data from a camera into an app using WIA 2.0 on a windows 7 machine using c#. The problem involves the timestamp. I don't want to transfer the image until I check if its timestamp is within a range. Here is the chopped down important part of the code. The sample here is from my test harness where I just do everything in one fell swoop, not from the real code. Again, I can make everything work fine if I ignore time, but that isn't an option.

WIA.DeviceManager devMgr = new WIA.DeviceManager();  
foreach (DeviceInfo info in devMgr.DeviceInfos)   
{  
   if (info.Type == WiaDeviceType.CameraDeviceType) //grab the first camera   
   {   
     cameraDevice = info.Connect();   
     break;   
   }   
} 

Here there is a loop of i items in the camera (each item is a pic at this point)

WIA.Item item = cameraDevice.Items[i];    
timestamp = item.Properties.get_Item("Item Time Stamp").get_Value().ToString();  

Now on that last line it just returns System.__ComObject. I have no idea how to get the value out of this object, I can't cast/transmutate it to anything useful, it has no properties I can find. Can anyone help me with getting the value out of this timestamp object?

On a side note, its amazing how few samples there are in the world of people using c# and WIA. Just sayin.

2

2 Answers

1
votes

This is what you want:

Vector timeTakenVector = (Vector)item.Properties["Item Time Stamp"].get_Value();
DateTime timeTaken = timeTakenVector.Date;