[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”)

Almost forgot

14 Responses to “[Windows Mobile]Stilling images from Camera C# or DirectShow .NETCF part III”

Pages: « 2 [1] Show All

  1. 10
    eric Says:

    Can i just still image without preview?

  2. 9
    N Says:

    Nice work.
    When video capture?
    Thanks for proyect!

  3. 8
    KenG Says:

    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).

  4. 7
    admin Says:

    digital zoom in/out you can do using IVideoWindow, thats not a problem

  5. 6
    Toyin Says:

    Another cool thing to have perhaps, might be the ability to zoom in and out before taking the picture.

  6. 5
    admin Says:

    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

  7. 4
    James Says:

    Fantastic work
    Some day you plan to do video capture and video streaming?

  8. 3
    Toyin Says:

    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?

  9. 2
    Toyin Says:

    How can one improve on the resolution?

  10. 1
    josh apelbaum Says:

    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

Pages: « 2 [1] Show All

Leave a Reply