Forum > PDAs and Smartphones

Web camera in WinCe

(1/2) > >>

proxy3d:

I'm trying to write a module receiving the camera images in WinCe.
1) There is a ready-made solutions to Lazarus to work with cameras in WinCe?
2) I did write the code to get a list of cameras in WinCe

--- Code: ---procedure TRVWebCam.CreateVideoDeviceList;
var
     hr      : Integer;
     hDriver : THandle;
     di      : TDEVMGR_DEVICE_INFORMATION;
     DeviceName : PWideChar;
     guidCam : TGUID;
     nCount  : Integer;
begin
  {$IFDEF wince}CoInitializeEx(nil, COINIT_APARTMENTTHREADED);{$ENDIF}

  hr        := S_OK;
  guidCam   := StringToGUID('{CB998A05-122C-4166-846A-933E4D7E3C86}');
  di.dwSize := sizeof(di);

  hDriver := FindFirstDevice( DeviceSearchByGuid, @guidCam, @di );

  nCount  := 0;
  SetLength(MArray, 100);
  if( hDriver <> INVALID_HANDLE_VALUE ) then
  begin
    FVideoDeviceList  := TStringList.Create;
    FVideoDeviceIndex := 0;

    repeat
      DeviceName:=AllocMem((MAX_PATH+1)*sizeof(WideChar));
      StrLCopy(DeviceName, di.szLegacyName, Length(TDEVMGR_DEVICE_INFORMATION.szLegacyName));
      FVideoDeviceList.Add(DeviceName);
      Freemem(DeviceName);

      DeviceName:=AllocMem((MAX_PATH+1)*sizeof(WideChar));
      StrLCopy(DeviceName, di.szDeviceName, Length(TDEVMGR_DEVICE_INFORMATION.szDeviceName));
      MArray[nCount] := DeviceName;
      Inc(nCount);
      Freemem(DeviceName);
    until not FindNextDevice( hDriver, @di );
    FindClose( hDriver );
  end else
  begin
    FVideoDeviceIndex := -1;
  end;
  SetLength(MArray, nCount);
end;
--- End code ---


3) I can not find the GUID to define interfaces for camera selection.
MSDN: http://msdn.microsoft.com/en-us/library/ms940046.aspx


--- Code: ---// Initialize the video capture filter
pVideoCap.CoCreateInstance( CLSID_VideoCapture );
pVideoCap.QueryInterface( &pPropertyBag );
varCamName = L"CAM1:";
if(( varCamName.vt == VT_BSTR ) == NULL ) {
  return E_OUTOFMEMORY;
}
PropBag.Write( L"VCapName", &varCamName );   
pPropertyBag->Load( &PropBag, NULL );
pPropertyBag.Release();
pGraph->AddFilter( pVideoCap, L"Video capture source" );
--- End code ---

lazarus:

--- Code: ---procedure SetCameraDriver( pGraph : IGraphBuilder; pwzName : WCHAR);
var
     FPropertyBag : IPropertyBag;
     pVideoCap    : IBaseFilter;
     hr           : HRESULT;
     PropBag      : <b>?????????????</b>;
begin
  // Initialize the video capture filter
  CoCreateInstance(CLSID_VideoCapture, NIL, CLSCTX_INPROC,
    IID_IBaseFilter, pVideoCap);

  hr:= pVideoCap.QueryInterface(IID_IPropertyBag, FPropertyBag);
  if Failed(hr) then exit;

  PropBag.Write( 'VCapName', pwzName );
  FPropertyBag.Read( @PropBag, NULL );
  FPropertyBag.Release();
  pGraph.AddFilter( pVideoCap, 'Video capture source');
end;
--- End code ---

I have a problem with the description PropBag. GUID? In Lazarus is a description of these interfaces?

proxy3d:
I try to solve problems for WinCE. In WinCe not implement interfaces SampleGrabber and NullRender

1) I am implementing SampleGrabber and Nullrenderer and class CTransInPlaceFilter and CBaseVideoRenderer
2) Another simple solution writing class VideoRendere. It is based on the class CBaseVideoRenderer, where you need to replace the two methods CheckMediaType and DoRenderSample
3) I'm trying to see the work DSPack, but when compiling I get errors. For example, the compiler writes that there is no CreateItemMoniker, but there CreateItemMoniker in WinCE.
http://msdn.microsoft.com/ru-ru/library/ms864395.aspx

The most simple solution is 2. If the rendering specify nil, the camera works and shows the video in a  window with the style of None, in the upper left.


--- Code: ---hr:=FCaptureGraphBuilder.RenderStream(@PIN_CATEGORY_CAPTURE,
                         @MEDIATYPE_Video,
                         FVideoCaptureFilter,
                         nil,
                         nil);
--- End code ---

proxy3d:
I try to use my VideoRenderer, which is the basis for the class CBaseVideoRenderer.


--- Code: ---    if Succeeded(CoCreateInstance(CLSID_FilterGraph, NIL, CLSCTX_INPROC_SERVER,
         IID_IGraphBuilder, FGraphBuilder)) then //Объект для графа фильтров
      if Succeeded(CoCreateInstance(CLSID_CaptureGraphBuilder, NIL,
          CLSCTX_INPROC_SERVER, IID_ICaptureGraphBuilder2, FCaptureGraphBuilder)) then
       FCaptureGraphBuilder.SetFiltergraph(FGraphBuilder); //Задаем граф фильтро

...
   FVideoRenderer := TRVVideoRenderer.Create(CLSID_RVVideoRenderer, 'VideoRenderer', nil, hr);
    if Failed(hr) then exit;
    hr:= FGraphBuilder.AddFilter(FVideoRenderer, 'VideoRenderer');
    if Failed(hr) then exit;
...
  hr:=FCaptureGraphBuilder.RenderStream(@PIN_CATEGORY_PREVIEW,
                         @MEDIATYPE_Video,
                         FVideoCaptureFilter,
                         nil,
                         FVideoRenderer)
--- End code ---

On RenderStream an exception. How do I find the line where the error occurs? In the file "lcldebug.log" no information about the exception. I understand that the call to the FVideoRenderer and error in them (I think I made ​​a mistake when implementing CBaseVideoRenderer). How do I know which line of code or a method generates an error?


--- Quote ---TApplication.HandleException Bus error or misaligned data access
  Stack trace:
  $4182A504
  $0020A4AC
  $4182CF58
--- End quote ---

proxy3d:
A simple solution to display in WebCamera WinCe, use CLSID_VideoRenderer. When the video output is possible to copy the video frame. For a 533MHz processor, the video from the camera is stretched to full screen 800x400 and displays fast (real frame resolution 200x200).
If each frame to use JPEG, it is slow.
How to Lazarus can speed JPEG? There are any solution?

BigChimp:

--- Quote from: proxy3d on August 17, 2013, 01:19:03 pm ---If each frame to use JPEG, it is slow.
How to Lazarus can speed JPEG? There are any solution?

--- End quote ---

You mean displaying JPEG on a desktop? You could look into imaging libraries such as imagemagick perhaps:
http://wiki.lazarus.freepascal.org/PascalMagick#About_PascalMagick

Other libraries like vampyre are perhaps also useful.

If on Windows CE: no idea if these libraries are ported/supported.

Navigation

[0] Message Index

[#] Next page

Go to full version