none
WPF网络摄像头 RRS feed

  • 问题

  • 我用CatenaLogic.Windows.Presentation.WebcamPlayer读取的视频画面,但是分辨率很低,请问在固定一个窗口下面,分辨率怎么调(譬如1920*1080),怎样将图片保存为较高像素呢?  

    2013年8月26日 13:45

答案

  • 您好,

    根据您的问题,我做了一些搜索,发现以下链接中有关于分辨率调整的解决方案:

    #WPF Webcam Control part 2
    http://blog.catenalogic.com/post/2009/01/08/WPF-Webcam-Control-part-2.aspx

    >>分辨率怎么调(譬如1920*1080)

    IEnumPins _enumPin; 
    _sourceObject.EnumPins(out _enumPin); 
    IPin[] _IPP = new IPin[3]; 
    int pt = -1; 
    _enumPin.Next(3, _IPP, out pt); 
         
    IAMStreamConfig st; 
    st = (IAMStreamConfig)_IPP[0]; 
         
    AMMediaType med = new AMMediaType(); 
    st.GetFormat(out med); 
    VideoInfoHeader head = (VideoInfoHeader)Marshal.PtrToStructure(med.FormatPtr, typeof(VideoInfoHeader)); 
    
    head.BmiHeader.Width = 960; 
    head.BmiHeader.Height = 720; 
    
    Marshal.StructureToPtr(head, med.FormatPtr, false); 
    st.SetFormat(med);


    >>怎样将图片保存为较高像素

    Capture_Executed中添加以下代码:
    FileStream stream1 = new FileStream("1.jpg", FileMode.Create); 
    JpegBitmapEncoder encoder1 = new JpegBitmapEncoder(); 
     
    encoder1.FlipHorizontal = true; 
    encoder1.FlipVertical = false; 
    encoder1.QualityLevel = 30; 
     
    encoder1.Frames.Add(BitmapFrame.Create(Bitmap)); 
    encoder1.Save(stream1);

    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    2013年8月27日 14:36
    版主

全部回复

  • 前提是你的摄像头支持高分辨率……
    2013年8月26日 13:50
  • 罗技的C920

    2013年8月27日 5:44
  • 您好,

    根据您的问题,我做了一些搜索,发现以下链接中有关于分辨率调整的解决方案:

    #WPF Webcam Control part 2
    http://blog.catenalogic.com/post/2009/01/08/WPF-Webcam-Control-part-2.aspx

    >>分辨率怎么调(譬如1920*1080)

    IEnumPins _enumPin; 
    _sourceObject.EnumPins(out _enumPin); 
    IPin[] _IPP = new IPin[3]; 
    int pt = -1; 
    _enumPin.Next(3, _IPP, out pt); 
         
    IAMStreamConfig st; 
    st = (IAMStreamConfig)_IPP[0]; 
         
    AMMediaType med = new AMMediaType(); 
    st.GetFormat(out med); 
    VideoInfoHeader head = (VideoInfoHeader)Marshal.PtrToStructure(med.FormatPtr, typeof(VideoInfoHeader)); 
    
    head.BmiHeader.Width = 960; 
    head.BmiHeader.Height = 720; 
    
    Marshal.StructureToPtr(head, med.FormatPtr, false); 
    st.SetFormat(med);


    >>怎样将图片保存为较高像素

    Capture_Executed中添加以下代码:
    FileStream stream1 = new FileStream("1.jpg", FileMode.Create); 
    JpegBitmapEncoder encoder1 = new JpegBitmapEncoder(); 
     
    encoder1.FlipHorizontal = true; 
    encoder1.FlipVertical = false; 
    encoder1.QualityLevel = 30; 
     
    encoder1.Frames.Add(BitmapFrame.Create(Bitmap)); 
    encoder1.Save(stream1);

    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    2013年8月27日 14:36
    版主
  • 非常感谢~~~~~
    2013年8月28日 2:25