|
If you want to make the preview invisible, change the following code inside CGraphManager::StartCaptureFramesInternal()
CHK (pVideoWindow->put_Visible(OATRUE));
To
CHK(pVideoWindow->put_Visible(OAFALSE));
However, the processing power will not be reduced in such cases. It would be best to create your own null renderer and attach it in the following line in CGraphManager::CreateCaptureGraphInternal():
Change:
CHK(m_pCaptureGraphBuilder->RenderStream(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_VIDEO, m_pVideoCaptureFilter, pH263Transform, NULL) ;
To
CHK(m_pCaptureGraphBuilder->RenderStream(&PIN_CATEGORY_PREVIEW, &MEDIATYPE_VIDEO, m_pVideoCaptureFilter, pH263Transform, /*YOUR NULL RENDERER HERE */) ;
after which, you can comment all the lines with regards to pVideoWindow in the CGraphManager::StartCaptureFramesInternal() since the default video renderer will not be used.
modified on Wednesday, April 28, 2010 11:12 PM
|
|
|
|
|
I have find the problem on my HTC HD2. The preview picture is rotated by 90 degrees. Has anyone met with this problem and is there any solution?
|
|
|
|
|
2 solutions to the problem:
1. If you are using your program in landscape mode, you can create a custom transInPlace filter that unsets the BI_SRCPREROTATE flag in your GetMediaType method. This will let the camera know that the phone is in the same orientation as the camera.
2. If you are using your program in potrait mode, you have to create a transform filter. In your transform method, you need to transpose your image inside there. From my experience, there is no easy solution for rotating preview if u are using potrait mode.
modified on Wednesday, April 28, 2010 11:11 PM
|
|
|
|
|
Hi Angel,
First of all, thank you for this DS filter code that you have given us. It is much appreciated!
I have read the faq forum, and have seen some questions about running this program under WM5.
However, I haven't seen anyone yet posting that de SampleGrabber worked under WM5.
I am now trying to get it to work under WM5, but I ran into an error I can't seem to resolve.
It happens inside the CreateBitmap method.
The moment CopyBitmap(ptrDst, ptrSrc, dstStride, srcStride, m_Height) is executed, I receive the error:
Error: ExceptionCode: 0x0000005
ExceptionAddress: 0x03fb2928
Reading: 0x0028d000
Everything else seems to run just fine (the preview works)
Have you got any idea what this error could be?
tnx,
Andre
|
|
|
|
|
It looks like CopyBitmap read from an invalid location. Check the datatype of the stream you are getting, what is the format of the frames? You can read more about copying video frames in the Windows Mobile SDK Documentation.
|
|
|
|
|
Figured out what the problem was:
In the application i clicked the start button before clicking the callback button.
This prevented the callback to the OnMediaTypeSet function to occur, which prevented the correct settings of the height, width, size and stride values.
I had noticed before that these values were missing, so I used 150 as default...and that is why the memory exception occured
But now with the correct values, the entire application is working just fine under WM5!
Thank you again for your contribution!
|
|
|
|
|
I am happy to hear that. Good luck!
|
|
|
|
|
Hi,
I am facing problem to compile source-7.67KB in VS2005.
Debug mode compilation succeed but Release compilation failed with the following linker errors:
SampleGrabberFilter.def : error LNK2001: unresolved external symbol DllCanUnloadNow
1>SampleGrabberFilter.def : error LNK2001: unresolved external symbol DllGetClassObject
1>Windows Mobile 6 Standard SDK (ARMV4I)\Release/SampleGrabberFilter.lib : fatal error LNK1120: 2 unresolved externals
Can someone please help me with this problem?
Regards,
Efi
|
|
|
|
|
Hi all, I am trying to have a filter graph which is based on the original sample codes. Camera Filter-> Encoder -> SampleGrabber -> Null Filter. However when i try to preview the video, with this 2 additions, the video doesnt show up.
Code as follows:
CHK(CoCreateInstance(CLSID_DMOWrapperFilter, NULL, CLSCTX_INPROC, IID_IBaseFilter, (void**)&pVideoEncoder));
CHK(pVideoEncoder->QueryInterface(&pWrapperFilter ));
CHK(pWrapperFilter->Init( CLSID_CWMV9EncMediaObject, DMOCATEGORY_VIDEO_ENCODER ));
CHK(m_pFilterGraph->AddFilter( pVideoEncoder, L"WMV9DMO Encoder"));
CHK( CoCreateInstance( CLSID_SampleGrabber, NULL, CLSCTX_INPROC, IID_IBaseFilter, (void**)&pH263Transform ) );
CHK( m_pFilterGraph->AddFilter( pH263Transform, FILTERNAME ) );
CHK( pH263Transform->QueryInterface( IID_ISampleGrabber, (void**)&m_pISampleGrabber ) );
CHK( CoCreateInstance( CLSID_NullRenderer, NULL, CLSCTX_INPROC, IID_IBaseFilter, (void**)&pNullRenderer ) );
CHK( m_pFilterGraph->AddFilter( pNullRenderer, L"NullRenderer" ) );
CHK( m_pCaptureGraphBuilder->RenderStream( &PIN_CATEGORY_CAPTURE,
&MEDIATYPE_Video, m_pVideoCaptureFilter, pVideoEncoder, pH263Transform ) );
CHK( m_pCaptureGraphBuilder->RenderStream( &PIN_CATEGORY_CAPTURE,
&MEDIATYPE_Video, pH263Transform, NULL, pNullRenderer ) );
CHK( m_pCaptureGraphBuilder->RenderStream( &PIN_CATEGORY_PREVIEW,
&MEDIATYPE_Video, m_pVideoCaptureFilter, pH263Transform, NULL ) );
Please advise me, thanks all!
|
|
|
|
|
maybe u might have already found the solution. But for others, these is the actual problem.
HK( m_pCaptureGraphBuilder->RenderStream( &PIN_CATEGORY_CAPTURE,
&MEDIATYPE_Video, m_pVideoCaptureFilter, pVideoEncoder, pH263Transform ) );
CHK( m_pCaptureGraphBuilder->RenderStream( &PIN_CATEGORY_CAPTURE,
&MEDIATYPE_Video, pH263Transform, NULL, pNullRenderer ) );
// preview stream
CHK( m_pCaptureGraphBuilder->RenderStream( &PIN_CATEGORY_PREVIEW,
&MEDIATYPE_Video, m_pVideoCaptureFilter, pH263Transform, NULL ) );
In your 1st m_pCaptureGraphBuilder->RenderStream , RenderStream only accepts 1 source, 1 intermediate and 1 renderer filter.
You cannot join a video encoder to a samplegrabber using renderstream. You need to connect the pins manually in cases where there are 2 or more intermediate filters.
In your 2nd m_pCaptureGraphBuilder->RenderStream, ph263 is not a source filter, hence it cannot be added in that parameter.
modified on Wednesday, April 28, 2010 11:12 PM
|
|
|
|
|
Hello Angel Kafazov
great article on creating a custom sample grabber filter which help me a lot!! I have developed an application that gets the camera frames
and processes them in order to do some object recognition. The resolution of the frames is 176*144 pixels.
What I need to do is, depending on my needs to be able to use a higher resolution frame e.g. 640*480 that will be obtained only when I press a button (I do not want a callback function that will return higher resolution frames all the time).
Is this doable?? I mean, can I get a higher resolution frame when I press a button while graph keeps running?
I suspect that the graph must stop getting the low resolution frames to return a higher resolution one. Also perhaps I should use the PIN_CATEGORY_CAPTURE or PIN_CATEGORY_STILL pins??
Regards
Demetrio
|
|
|
|
|
Hi Demetrio,
yes this can be done. The PINs in the graph have nothing to do with the resolution. I suppose that you will have to restart the graph and accept the higher resolutions which the camera offers. It all depends on the device and how much is DirectShow supported on it.
Regards,
Angel
|
|
|
|
|
Hello Angel,
thanks for the reply. I will try your suggestion and see how it goes. I was also thinking if I can add to the my program functionality for storing images when i need to (like the cameracapture in the microsoft sdk samples). Storing the image might solve my problem since when I tried the cameracapture sample (on the same phone I am using now) it would only store images of 640*480 resolution.
Regards
Demetrio
|
|
|
|
|
Hi Demetrio,
I have the same problem.
Could you find a way to get higher resolution?
thanks...
alper
|
|
|
|
|
can anybody help me?I have a big problem:
When I try to stop the filter graph,it doesn't work at all and Next time I want to execute the program again,there always was an error that the camera was in use.
|
|
|
|
|
Hi,
Thank you for the excellent code. I understand most of it, however, it does not run on the HTC Diamond Touch. I put traces in the code. It seems to Initialize properly, but Transform is not being called at all. Could you tell me what the problem could be ?
Regards
Vidya
modified on Wednesday, November 18, 2009 1:50 PM
|
|
|
|
|
hi,
I've got the same problem... can complie fine in releasemode, but nothing happens... the screen stays white and the breakpoints in pressing-methods are nerver hit.
Has anyone an idea? need a solution for showing a video preview and alanysing each video-fram (without saving them to disk )
thanks for your help
|
|
|
|
|
Hello,
I get this error. I go to project properties --> deployment and switch "Register Output" to Yes.
But the error is still there. How I can solve it?
and, this is why in the TestCameraCapture I only see "Processed image", "register callback" and "Start" and I don´t see any image pressing any button
Thanks
Luis
|
|
|
|
|
Dear Angel Kafazov,
Firstly, I thank for your good job very much.
It really solve my "big problem".
After many hard work, I can use this samplegrabber filter very well in my Windows Mobile 6.0 PDA now.
But when I want to use it on Windows Mobile 5.0. It doesn't work.
The filter (dll) is fail to be registered. Do you use it well on wm 5 ?
Could you plz give me some hints or experiences to work on wm 5.0 ?
Thanks very much.
ps. I use the file from this link on your page:
Download sample C# client project with modified CameraCaptureDLL - 32.91 KB
|
|
|
|
|
You should be able to compile the filter for WM5. Just create a WM5 project and deploy. Let me know what errors you are getting.
|
|
|
|
|
Hello, thanks your quickly reply.
I change the project to wm 5.0 and remove 'CodecH263CE.lib'.
Also, I add some code in Class CSampleGrabber to solve NonDelegatingRelease() problem on compiling time just like i do well on wm 6.0.
The code is as follow.
#ifdef DEBUG
STDMETHODIMP_(ULONG) NonDelegatingRelease()
{
return ULONG(0);
}
#endif
I compile and deploy it correctly. But when i run it, VS2008 pops out a messagebox. It shows the following information:
Unhandled exception at 0X009955ac in MyTestGrabber.exe:0x80000002: Datatype misalignment.
|
|
|
|
|
Hi all,
I have WindowsMobile6 Professional SDK and WindowsMobile 5.0 PocketPC SDK installed on my computer. Abt the baseclasses, i downloaded the Feb2005 Directshow Extras, must we compile it? I don't have wince sdk installed. Please advise.
In the project sample it requires:
C++ Include:
decoder;
encoder;"
E:\Program Files\Windows Mobile 6 SDK\PocketPC\Include\Armv4i";..\include;
// I have this installed
E:\WINCE500\PUBLIC\DIRECTX\SDK\INC;
// Which folder should I link this to ?
E:\WINCE50\PUBLIC\DIRECTX\SDK\SAMPLES\DSHOW\BASECLASSES
//can i use this -> C:\Program Files\Microsoft DirectX Extras (Feb 2005)\Extras\DirectShow\Samples\C++\DirectShow\BaseClasses ?
Linker Include:
E:\WINCE500\PUBLIC\DIRECTX\SDK\LIB\ARMV4I\DEBUG
//Same problem as above. Is it referring to the Windows Mobile 6 SDK ??
Hope you can help me on this, this project means a lot to me. Thanks lots
|
|
|
|
|
When I said you need to install those specific libraries it was not accidental, wince included. You can delete the decoder/encoder references.
|
|
|
|
|
Hey guys. I've read the messages and was able to handle some errors with the project compiling. However, after compiling successfully, I run the program on my HTC Diamond and it doesnt show any images.
While testing, I found out that the messages from the CameraCaptureDLL we're getting through to the TestCameraCapture. To solve this, I changed this:
// Init camera dll
Init(this.Handle);
// init events window
MsgWindow wnd = new MsgWindow(this);
SetEventsWindow(wnd.Hwnd);
To this:
// init events window
MsgWindow wnd = new MsgWindow(this);
// Init camera dll
Init(wnd.Hwnd);
SetEventsWindow(wnd.Hwnd);
And like this the events were available for processing. Even so, no images are processed.
Apparently, the starting up is OK, since it returns "true" for the start() method...
I've managed to get similar projects working with preview window and still capture, but frame grabber's I haven't been able to find a code that works on this mobile
Anyone had the same kind of problem? Any clues how to solve this?
Thanks in advance.
Gustavo
|
|
|
|
|
Hi all, I have an error when I tried to initialize the samplegrabber filter. I am using it as a class in my C++ WTL mobile project in vs 2008 pro.
hr = CoCreateInstance( CLSID_SampleGrabber, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&m_pSampleGrabber);
Error: hr 0x80040154 {Class not registered } HRESULT
hr = m_pFilterGraph->AddFilter(m_pSampleGrabber, FILTERNAME_SGrabber);
Error: hr 0x80004003 {E_POINTER} HRESULT
My graphmanager header inclusion:
#pragma once
#include "stdafx.h"
#include <windows.h>
//#include <initguid.h> clsid for nullrenderer, samplegrabber and dmofiltercategory already defined
//#include <camera.h> error due to struct and macro redefinition in ddraw.h
#include "SampleGrabber.h"
#include "SampleGrabberGuid.h"
#include "CamServer.h" my graphmanager header file
#include "mycallback.h"
I did include the SampleGrabber.h and SampleGrabberGuid.h in SampleGrabber.cpp, I don't know why there is an error. Please advise, thanks all !
modified on Sunday, October 4, 2009 12:55 AM
|
|
|
|
|