Video

AXELMEDICAL Messages postés 96 Date d'inscription mercredi 26 mai 2010 Statut Membre Dernière intervention 27 mai 2010 - 4 janv. 2007 à 12:26
AXELMEDICAL Messages postés 96 Date d'inscription mercredi 26 mai 2010 Statut Membre Dernière intervention 27 mai 2010 - 4 janv. 2007 à 13:05
Salut j'ai integre une partie de code qui n'est pas à moi....
Voila je fais de la capture video lors de la premiere capture tout va bien ,mais lorsque que je close ma fenetre qui contient la panelVideo et que je veux  la Show une deuxieme fois une erreur apparait "la vlauer n'est pas comprise dans la plage attendu".

2 réponses

MorpionMx Messages postés 3466 Date d'inscription lundi 16 octobre 2000 Statut Membre Dernière intervention 30 octobre 2008 57
4 janv. 2007 à 12:40
Salut,

C'est embétant.
Surtout si on a pas l'erreur exacte, la le bout de code qui va pour qu'on puisse voir ou se trouve le souci, etc.

Mx
MVP C# 
0
AXELMEDICAL Messages postés 96 Date d'inscription mercredi 26 mai 2010 Statut Membre Dernière intervention 27 mai 2010
4 janv. 2007 à 13:05
bool
SetupGraph(){


int
hr;


try

{


hr = capGraph.SetFiltergraph( graphBuilder );







if
( hr < 0 )


Marshal
.ThrowExceptionForHR( hr );hr = graphBuilder.AddFilter( capFilter,


"Ds.NET Video Capture Device"
);


if
( hr < 0 )


Marshal
.ThrowExceptionForHR( hr );


//DsUtils.ShowCapPinDialog( capGraph, capFilter, this.Handle );

ShowCapPinDialog(capGraph, capFilter,




this
.Handle);


AMMediaType
media =

new



AMMediaType
();media.majorType =


MediaType
.Video;media.subType =


MediaSubType
.RGB24;media.formatType =


FormatType
.VideoInfo;

// ???

hr = sampGrabber.SetMediaType( media );










if
( hr < 0 )


Marshal
.ThrowExceptionForHR( hr );hr = graphBuilder.AddFilter( baseGrabFlt,


"Ds.NET Grabber"
);


if
( hr < 0 )


Marshal
.ThrowExceptionForHR( hr );


Guid
cat =

PinCategory
.Preview;


Guid
med =

MediaType
.Video;hr = capGraph.RenderStream(


ref
cat,

ref
med, capFilter,

null
,

null
);

// baseGrabFlt   MON ERREUR EST ICI






if
( hr < 0 )


Marshal
.ThrowExceptionForHR( hr );

cat =


PinCategory
.Capture;med =


MediaType
.Video;

hr = capGraph.RenderStream(


ref
cat,

ref
med, capFilter,

null
, baseGrabFlt );

// baseGrabFlt









if
( hr < 0 )


Marshal
.ThrowExceptionForHR( hr );media =


new



AMMediaType
();

hr = sampGrabber.GetConnectedMediaType( media );


if
( hr < 0 )


Marshal
.ThrowExceptionForHR( hr );


if
( (media.formatType !=

FormatType
.VideoInfo) || (media.formatPtr ==

IntPtr
.Zero) )


throw



new



NotSupportedException
(

"Unknown Grabber Media Format"
);videoInfoHeader = (


VideoInfoHeader
)

Marshal
.PtrToStructure( media.formatPtr,

typeof
(

VideoInfoHeader
) );


Marshal
.FreeCoTaskMem( media.formatPtr ); media.formatPtr =

IntPtr
.Zero;hr = sampGrabber.SetBufferSamples(


false
);


if
( hr 0 )hr sampGrabber.SetOneShot(


false
);


if
( hr 0 )hr sampGrabber.SetCallback(


null
, 0 );


if
( hr < 0 )


Marshal
.ThrowExceptionForHR( hr );


return



true
;}


catch
(

Exception
ee ){


MessageBox
.Show(

this
,

"Could not setup graph\r\n"
+ ee.Message,

"DirectShow.NET"
,

MessageBoxButtons
.OK,

MessageBoxIcon
.Stop );


return



false
;}
0
Rejoignez-nous