Click here to Skip to main content
15,860,972 members
Home / Discussions / COM
   

COM

 
GeneralRe: Create a new system Calendar for Windows (unmanaged code) Pin
Getterdonne3-Sep-16 13:13
professionalGetterdonne3-Sep-16 13:13 
QuestionC# Invoking Context menu item programmatically. Pin
Member 1223225328-Mar-16 0:39
Member 1223225328-Mar-16 0:39 
QuestionCreating an IShellLink in .NET Pin
Richard Andrew x6429-Dec-15 15:42
professionalRichard Andrew x6429-Dec-15 15:42 
QuestionTrouble with implement Com Local Server Pin
Tri Cuong26-Sep-15 7:00
Tri Cuong26-Sep-15 7:00 
AnswerRe: Trouble with implement Com Local Server Pin
Richard MacCutchan26-Sep-15 20:47
mveRichard MacCutchan26-Sep-15 20:47 
GeneralRe: Trouble with implement Com Local Server Pin
Tri Cuong3-Oct-15 7:29
Tri Cuong3-Oct-15 7:29 
GeneralRe: Trouble with implement Com Local Server Pin
Richard MacCutchan4-Oct-15 2:41
mveRichard MacCutchan4-Oct-15 2:41 
QuestionWhy is the resolution in SampleGrabber different from the resolution in IAMStreamConfig? Pin
garry.fang24-Jun-15 12:44
garry.fang24-Jun-15 12:44 
Dear All,

I am doing some development with a Logitech C920. I tried to maximize the resolution of C920 to 1920X1080, which it can support. The setting is successful as hr is S_OK. Then I use a samplegrabber to get the image, which is always 640X480. Something is wrong. I am brand new to DirectShow. All my code is based on other's sample code. So, could anyone give me a help?

Best,

Gary

/////////////////////////////////////////////////////////////
void videoCapture::SetResolution(IBaseFilter* pSrcFilter, int Width, int Height)
{
IAMStreamConfig *pConfig = NULL;
pCapture->FindInterface(&PIN_CATEGORY_STILL,
&MEDIATYPE_Video, pSrcFilter, IID_IAMStreamConfig, (void**)&pConfig);

int resolutions, size;
VIDEO_STREAM_CONFIG_CAPS caps;
pConfig->GetNumberOfCapabilities(&resolutions, &size);

for (int i = 0; i < resolutions; i++)
{
AM_MEDIA_TYPE *mediaType;
if (pConfig->GetStreamCaps(i, &mediaType,
reinterpret_cast<byte*>(&caps)) == S_OK)
{
int maxWidth = caps.MaxOutputSize.cx;
int maxHeigth = caps.MaxOutputSize.cy;

if (maxWidth == Width && maxHeigth == Height)
{
VIDEOINFOHEADER *info = reinterpret_cast<videoinfoheader*>(mediaType->pbFormat);

info->bmiHeader.biWidth = maxWidth;
info->bmiHeader.biHeight = maxHeigth;
info->bmiHeader.biSizeImage = DIBSIZE(info->bmiHeader);
HRESULT hr = pConfig->SetFormat(mediaType);

DeleteMediaType(mediaType);
break;
}

DeleteMediaType(mediaType);
}
}

SAFE_RELEASE(pConfig);
}

/////////////////////////////////////////////////////////////

HRESULT videoCapture::CaptureVideo(unsigned int devIndex)
{
if (devIndex == 0)
devIndex = 1;

HRESULT hr;
IBaseFilter *pSrcFilter = NULL;

// Attach the filter graph to the capture graph
hr = pCapture->SetFiltergraph(pGraph);
if (FAILED(hr)) {
Msg(TEXT("Failed to set capture filter graph! hr=0x%x"), hr);
return hr;
}

// Use the system device enumerator and class enumerator to find
// a video capture/preview device, such as a desktop USB video camera.
hr = FindCameraDevice(&pSrcFilter);
if (FAILED(hr)) {
// Don't display a message because FindCaptureDevice will handle it
return hr;
}


// Add Capture filter to our graph.
hr = pGraph->AddFilter(pSrcFilter, L"Video Capture");
if (FAILED(hr)) {
Msg(TEXT("Couldn't add the capture filter to the graph! hr=0x%x\r\n\r\n")
TEXT("If you have a working video capture device, please make sure\r\n")
TEXT("that it is connected and is not being used by another application.\r\n\r\n")
TEXT("The sample will now close."), hr);
SAFE_RELEASE(pSrcFilter);
return hr;
}

hr = SetCameraExposure(pSrcFilter, 100);

hr = pImageGrabber->InitSampleGrabber(pGraph);
if (FAILED(hr)) {
Msg(TEXT("Couldn't add the SampleGrabber filter to the graph! hr=0x%x"), hr);
return hr;
}

hr = pImageGrabber->SetSampleGrabberMediaType();
if (FAILED(hr)) {
Msg(TEXT("Couldn't set the SampleGrabber media type! hr=0x%x"), hr);
return hr;
}

SetResolution(pSrcFilter, 1920, 1080);

IBaseFilter* pGrabber = pImageGrabber->GetSampleGrabber();
hr = pCapture->RenderStream(NULL, &MEDIATYPE_Video,
pSrcFilter, pGrabber, NULL);

hr = pImageGrabber->GetSampleGrabberMediaType();
if (FAILED(hr)) {
Msg(TEXT("Couldn't get the SampleGrabber media type! hr=0x%x"), hr);
return hr;
}

// Now that the filter has been added to the graph and we have
// rendered its stream, we can release this reference to the filter.
SAFE_RELEASE(pSrcFilter);

#ifdef REGISTER_FILTERGRAPH
// Add our graph to the running object table, which will allow
// the GraphEdit application to "spy" on our graph
hr = AddGraphToRot(g_pGraph, &g_dwGraphRegister);
if (FAILED(hr)) {
Msg(TEXT("Failed to register filter graph with ROT! hr=0x%x"), hr);
g_dwGraphRegister = 0;
}
#endif

// Start previewing video data
hr = pMC->Run();
if (FAILED(hr)) {
Msg(TEXT("Couldn't run the graph! hr=0x%x"), hr);
return hr;
}

return S_OK;
}
QuestionC#: Fixed Function ID in COM DLL Pin
DoxMan20-Apr-15 23:52
DoxMan20-Apr-15 23:52 
AnswerRe: C#: Fixed Function ID in COM DLL Pin
Richard Deeming21-Apr-15 2:37
mveRichard Deeming21-Apr-15 2:37 
AnswerRe: C#: Fixed Function ID in COM DLL Pin
F-ES Sitecore29-Apr-15 4:09
professionalF-ES Sitecore29-Apr-15 4:09 
QuestionIoleUndoManager with Excel application Pin
jaafar tribak6-Apr-15 5:28
jaafar tribak6-Apr-15 5:28 
QuestionEXCEL - Hooking Excel VTABLE Pin
jaafar tribak3-Apr-15 17:53
jaafar tribak3-Apr-15 17:53 
AnswerRe: EXCEL - Hooking Excel VTABLE Pin
jaafar tribak17-Apr-15 13:59
jaafar tribak17-Apr-15 13:59 
QuestionHow to generate an early-bound COM object in VS2013 Pin
CrewR4-Mar-15 6:50
CrewR4-Mar-15 6:50 
SuggestionHow to reference IWshRuntimeLibrary Pin
ThanhTrungDo2-Mar-15 17:24
professionalThanhTrungDo2-Mar-15 17:24 
GeneralRe: How to reference IWshRuntimeLibrary Pin
Richard MacCutchan2-Mar-15 21:27
mveRichard MacCutchan2-Mar-15 21:27 
QuestionRegistration Free COM / COM Interop Pin
Michael Salzlechner8-Feb-15 3:28
Michael Salzlechner8-Feb-15 3:28 
AnswerRe: Registration Free COM / COM Interop Pin
F-ES Sitecore2-Mar-15 4:55
professionalF-ES Sitecore2-Mar-15 4:55 
GeneralRe: Registration Free COM / COM Interop Pin
DriveByCoder24-Mar-15 7:18
professionalDriveByCoder24-Mar-15 7:18 
GeneralRe: Registration Free COM / COM Interop Pin
F-ES Sitecore24-Mar-15 8:12
professionalF-ES Sitecore24-Mar-15 8:12 
QuestionHow to SubClass ContentControl in MSWORD Pin
Member 1017975812-Dec-14 16:07
Member 1017975812-Dec-14 16:07 
QuestionDCOM CLASSNOTREG error Pin
Billy Bang19-Nov-14 18:58
Billy Bang19-Nov-14 18:58 
AnswerRe: DCOM CLASSNOTREG error Pin
Richard MacCutchan19-Nov-14 21:29
mveRichard MacCutchan19-Nov-14 21:29 
GeneralRe: DCOM CLASSNOTREG error Pin
Billy Bang19-Nov-14 21:48
Billy Bang19-Nov-14 21:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.