aforge.net。在VideoCaptureDevice类中,DesiredFrameSize属性对我不起作用。 [英] aforge.net. in class VideoCaptureDevice, DesiredFrameSize property is not working for me.

查看:1183
本文介绍了aforge.net。在VideoCaptureDevice类中,DesiredFrameSize属性对我不起作用。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨朋友

类VideoCaptureDevice,DesiredFrameSize属性对我不起作用,告诉我(1)中的错误在哪里?与(1)问题相同我也想设置自定义DesiredFrameRate属性。

(1):

Hi Friends
class VideoCaptureDevice, DesiredFrameSize property is not working for me, tell me where is mistake in (1)? same as (1) problem I also want to set custom DesiredFrameRate property.
(1):

videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice );
VideoCaptureDevice videoSource = new VideoCaptureDevice(videoDevices[0].MonikerString );
videoSource.NewFrame += new NewFrameEventHandler( video_NewFrame );
//
selectedCamera.DesiredFrameSize = new Size(200, 200); //no any result
//
videoSource.Start( );

private void video_NewFrame( object sender,
        NewFrameEventArgs eventArgs )
{
   MessageBox.Show(eventArgs.Frame.Size.ToString());  //message box shows (640,480) not as configred       
 //...
}



(2)工作正常,但我想在(1)中使用DesiredFrameSize。

i也尝试了以下内容并且在框架上工作正常。


(2)its working fine, but I want to use DesiredFrameSize as in (1).
i also tried the following and it is working fine on the frame.

public static ResizeNearestNeighbor size = new ResizeNearestNeighbor(200,200);
//
Bitmap bitmap = size.Apply( eventArgs.Frame);
   MessageBox.Show(bitmap.Size.ToString());  //working fine
//..

推荐答案

我从未尝试过AForge.NET DesiredFrameSize ,但我认为它不可能设置你想要的任何尺寸。摄像机通常具有一些预定义模式,并且一些模式具有不同的帧大小。如果您要求的尺寸是由其中一种可用模式支持的,那么它将起作用,如果没有 - 它不会。



-SA
I never tried AForge.NET DesiredFrameSize, but I don't think it can possibly set any size you may wish. The cameras usually have some set of predefined modes, and some modes have different frame size. If your requested size is supported by one of the available modes, it will work, if not — it won't.

—SA


会员8973214写道:
Member 8973214 wrote:

是的,以下链接显示如何在windows中创建键盘快捷方式打开一个应用程序[一些不相关的链接,删除 - SA],但我想通过C#代码执行此操作。

Yeah, the following link shows how to create keyboard shortcut in windows to open an application [some irrelevant link, removed — SA], but I want to do this via C# code.

请参阅我对解决方案1的最后评论。



您可能希望以下列两种方式之一进行:1)您可以让某些应用程序听一些全局键盘快捷键并激活自身;记住应用程序无法自行启动;还记得应用程序独立定义快捷方式,因此不同的应用程序可能会发生冲突; 2)你可以有一个单独的经理应用程序,并注册一些要启动或激活的应用程序。



首先你需要了解,你要问的是关于快捷方式,与每个应用程序中使用的常用快捷方式无关。如果您进行网络搜索,几乎所有搜索结果都是关于那些常规快捷方式,而不是您要询问的那些。



在这两种情况下,您都需要使用 Windows Hooks http://msdn.microsoft.com/en-us/library/windows/desktop/ms632589%28v=vs.85%29.aspx [ ^ ]。



此外,在这两种情况下,你需要使你的钩子 system-global 。根据Microsoft文档,它将需要在某些 native DLL中安装钩子。这意味着你不能在C#中完全做到这一点。您只能在C#中使用主应用程序,但是应该加载本机DLL并将其用于挂钩安装。而且,钩子永远不会捕获在同一个线程中。您需要使用一些与线程无关的方式来处理钩子处理程序和应用程序之间的通信,可能使用IPC( http:// en.wikipedia.org/wiki/Inter-process_communication [ ^ ]。



有主要想法?比尝试实现它,但我会警告你:这将是一项相当大的工作,并且钩子功能很难调试。与此同时,我非常确定有可用的应用程序几乎完全相同。所以:它值得吗? :-)



-SA

Please see my last comment to Solution 1.

You may want to do it in one of the two ways: 1) you can make some applications listen to some global keyboard shortcut and activate itself; remember that the application cannot start itself; also remember that applications define the shortcuts independently, so the different application may conflict; 2) you can have a separate "manager" application and register some of the applications to be started or activate.

First thing you need to understand, that you are asking about "shortcuts" which has nothing to do with usual shortcuts used inside each application. If you do the Web search, almost all search results will be about those "regular" shortcuts, not those you are asking about.

In both cases, you will need to use Windows Hooks: http://msdn.microsoft.com/en-us/library/windows/desktop/ms632589%28v=vs.85%29.aspx[^].

Moreover, in both cases you need to make your hooks system-global. According to Microsoft documentation, it will require the hook installed in some native DLL. It means that you cannot do it fully in C#. You can only have the main application in C#, but is should load the native DLL and use it for hook installation. Moreover, the hook is never captures in the same thread. You will need to use some thread-independent way to communication between the hook handler and the application, possibly using IPC (http://en.wikipedia.org/wiki/Inter-process_communication[^]).

Got the main idea? Than try to implement it, but I'll warn you: it will be pretty big work, and hook functionality is quite hard to debug. At the same time, I'm pretty sure there are available applications which do pretty much the same. So thing: does it worth it? :-)

—SA


private void Form1_Load(object sender,EventArgs e)< br $>
{

videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

VideoCaptureDevice videoSource = newVideoCaptureDevice(videoDevices [0] .MonikerString);

videoSource.NewFrame + = new NewFrameEventHandler(video_NewFrame);

//videoSource.VideoResolution = videoSource.VideoCapabilities [0];

videoSource.DesiredFrameSize = new大小(752,582); //没有任何结果

//

videoSource.Start();

}





private void video_NewFrame(object sender,NewFrameEventArgs eventArgs)

{

video =(Bitmap)eventArgs.Frame.Clone( );

Cam1.Image =(Bitmap)eventArgs.Frame.Clone();

// MessageBox.Show(eventArgs.Frame.Size.ToString());



}





任何一个帮助......怎么做改变分辨率。

此代码是任何相机使用,可以使用640x480分辨率。

i想要使用分辨率1920x1080,
private void Form1_Load(object sender, EventArgs e)
{
videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
VideoCaptureDevice videoSource = newVideoCaptureDevice(videoDevices[0].MonikerString);
videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
//videoSource.VideoResolution = videoSource.VideoCapabilities[0];
videoSource.DesiredFrameSize = new Size(752, 582); //no any result
//
videoSource.Start();
}


private void video_NewFrame( object sender, NewFrameEventArgs eventArgs )
{
video = (Bitmap)eventArgs.Frame.Clone();
Cam1.Image = (Bitmap)eventArgs.Frame.Clone();
// MessageBox.Show(eventArgs.Frame.Size.ToString());

}


any one help... how to do change resolution.
this code is any camera use, can use 640x480 resolution.
i want to use resolution 1920x1080,


这篇关于aforge.net。在VideoCaptureDevice类中,DesiredFrameSize属性对我不起作用。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆