[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
March 1st, 2010 at 2:56 pm
what code? you can buy library and will have code
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
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.
July 14th, 2009 at 8:04 pm
Yep