[Windows Mobile]Stilling images from Camera C# or DirectShow .NETCF part III
Ok, most popular question for last week was: “How to still images from windows mobile camera?”
I finished my project little bit earlier that i was planing, so i have free time again and looking for job too
So what do we need? tons extra com interfaces (Ipin, IEnumPins, IEnumFilters, IFileSinkFilter, IAMVideoControl and so on).
Also i implemented 2 useful classes (as for me) CPinList and CFilterList (the same as in DSPack).
public class CFilterList
{
private List<IBaseFilter> Filters;
private IEnumFilters enumFilters = null;
public CFilterList()
{
Filters = new List<IBaseFilter>();
}
~CFilterList()
{
Free();
Filters = null;
}
public void Assign(IGraphBuilder fg)
{
Clear();
fg.EnumFilters(out enumFilters);
IBaseFilter Filter;
int fetched = 0;
while (enumFilters.Next(1, out Filter, out fetched) == 0)
{
Filters.Add(Filter);
}
Marshal.ReleaseComObject(enumFilters);
enumFilters = null;
}
public int Count
{
get
{
return Filters.Count;
}
}
public IBaseFilter this[int index]
{
get
{
return Filters[index];
}
}
public void Free()
{
Clear();
}
private void Clear()
{
while (Filters.Count > 0)
{
Marshal.ReleaseComObject(Filters[0]);
Filters[0] = null;
Filters.RemoveAt(0);
}
Filters.Clear();
}
}
public class CPinList
{
private List<IPin> Pins = null;
private IEnumPins enumPins = null;
public CPinList()
{
Pins = new List<IPin>();
}
~CPinList()
{
Free();
Pins = null;
}
public int Count
{
get
{
return Pins.Count;
}
}
public IPin this[int index]
{
get
{
return Pins[index];
}
}
public void Assign(IBaseFilter filter)
{
Clear();
filter.EnumPins(out enumPins);
IPin pin;
int fetched = 0;
while (enumPins.Next(1, out pin, out fetched) == 0)
{
Pins.Add(pin);
}
Marshal.ReleaseComObject(enumPins);
enumPins = null;
}
private void Clear()
{
while (Pins.Count > 0)
{
Marshal.ReleaseComObject(Pins[0]);
Pins[0] = null;
Pins.RemoveAt(0);
}
Pins.Clear();
}
public void Free()
{
Clear();
}
}
so now stilling images works, btw in the same time with preview, but there some bad news (if we can call it so):
a) it takes like 15 seconds to build graph ![]()
b) when i still image preview hangs for like 2 seconds.
good news:
a) we can implement samplegrabber filter and do not wait when stilling images and building graph
b) filter of video capture device has 3 output pins (on my device), i`m not sure, but seems like: preview, still image and probably still video
will try to check it soon
And last one perhaps preview and stilling images wont work on some devices in the same time so you will need to choose what exactly you need (but this is only unconfirmed “perhaps”)
Filed under: Programming
June 14th, 2009 at 4:53 am
hi Alex, awesome articles/sources, thanks!
I’m looking for away to overlay a video with text or image (becuase VMR is not available for windows mobile)
hopefully you or anyone else around can drop me a clue about it
thanks
June 14th, 2009 at 10:36 am
How can one improve on the resolution?
June 14th, 2009 at 11:16 am
Secondly, the paint event doesn’t fire. I’m trying to create a target area, so that I can narrow the focus on the image. I’m guessing it has something to do with the run method, holding the panel to ransom. How can one solve this problem?
June 14th, 2009 at 4:59 pm
Fantastic work
Some day you plan to do video capture and video streaming?
June 14th, 2009 at 7:47 pm
2 josh apelbaum, you need to implement transfor filter or TranceInPlace
2 James, perhaps, dont know yet, what to do next
2 Toyin, resolution maybe will explaine in next article, paint event aint easy but possible, have to check first
June 14th, 2009 at 10:38 pm
Another cool thing to have perhaps, might be the ability to zoom in and out before taking the picture.
June 15th, 2009 at 4:01 pm
digital zoom in/out you can do using IVideoWindow, thats not a problem
June 15th, 2009 at 5:02 pm
Tested DirectShowNETCF.dll on Motorola MC55 works great. Look forward to testing future versions with ability to enumerate/set resolutions (IAMStreamConfig interface) and hopefully a better performing sample grabber filter implementation to capture still images. Also the ability to turn the camera flash on and off would be a nice feature (IAMCameraControl interface).
June 15th, 2009 at 5:39 pm
Nice work.
When video capture?
Thanks for proyect!
July 12th, 2009 at 8:14 pm
Can i just still image without preview?
July 14th, 2009 at 8:04 pm
Yep
February 26th, 2010 at 9:10 pm
Hi Alex, congratulations for your blog, its very useful.
Im testing DirectShowNETCF to timed capture images (withou preview - its an automatic process).
I find that when firing screen saver, its imposible capture images. You know how I can programmatically in C# prevent/disable the screen saver before capturing the images and then back on?
Thanks.
February 28th, 2010 at 9:55 am
I’m confuje for that plz help me
plz send me that code how to capture image i realy
want that
3days i’m trying that thing plz help me my last date is 2mmaro
regards: chetan
March 1st, 2010 at 2:56 pm
what code? you can buy library and will have code