Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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):
C#
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)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.
C#
public static ResizeNearestNeighbor size = new ResizeNearestNeighbor(200,200);
//
Bitmap bitmap = size.Apply( eventArgs.Frame);
   MessageBox.Show(bitmap.Size.ToString());  //working fine
//..
Posted
Updated 24-May-18 17:40pm
v4

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
 
Share this answer
 
Comments
Member 8973214 14-May-13 15:57pm    
Superb. :-)
yes It true. thanks. now I tried standard size ratio (320,240) and (1280 , 720) etc, which 100% worked with DesiredFrameSize property. again ***** for you.:)
Sergey Alexandrovich Kryukov 14-May-13 16:12pm    
"*****"... Good that it wasn't a four-star word. :-)

You are very welcome.
Good luck, call again.

—SA
Member 8973214 14-May-13 17:18pm    
yeah Five Start ;-).
Sure..
Sergey Alexandrovich Kryukov 14-May-13 17:37pm    
:-)
Member 8973214 17-May-13 15:11pm    
Hi SA, I want to register a KeyBoard shortcut with code to run my application which is being developed in C#. (eg: as "Ctrl+Alt+Del" is most popular). I could not find any related stuff.
Member 8973214 wrote:
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.
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
 
Share this answer
 
Comments
Member 8973214 18-May-13 12:50pm    
Hmmmmm :-) I Got the Idea and Its looking a complex work, for Now I am leaving it and shall try it in free time. But thanks for your time. :-)
Sergey Alexandrovich Kryukov 18-May-13 21:59pm    
You are very welcome.
Good luck,
—SA
Member 13785296 24-May-18 23:42pm    
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,
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,
 
Share this answer
 
Comments
Patrice T 25-May-18 0:14am    
Open your own question and delete this

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900