DirectShowNet and annoying screen - c#

I'm using DirectShowNet.dll to grab a photo
of my web camera.
Anytime my camera initializes it first shows me this
screen. Where can I turn it off?
http://www.goat-it.com/!tino/screen.jpg

Looks like your code is pulling up the prop pages for your camera. I have only been able to get this property page to show if I explicitly write code to do it. How are you getting the image? Graph -> CaptureGraphBuilder2 + SampleGrabber -> SampleGrabberCB?

You could use the Win32 FindWindow command to find it and then send a WM_COMMAND to press the OK button?
Edit: Well if you want to do it the more "proper" way (Though my experience is from the C++ end, but I assume its much the same) you may want to locate the video capture filter. Once you've located that you can query interface it to see if you can access its IPropertyPage (IIRC) interface. If you can then you should just be able to call Deactivate.
Alas I don't have access to a webcam at the moment so I can't check on how exactly to do this ...
Are you using the ICaptureGraphBuilder? If so it may well be worth learning how to enumerate all the devices and attach them together yourself. It will give you a MUCH better understanding of whats going on :)

Related

World of Warcraft image processing

As I´ve looked for a way to create an addon, which checks the WoW-PvP-Queue-Status, for creating a REST service, I was told that it`s not possible to have a real-time connection between an addon and a REST service. So I was thinking about another way to solve my problem and came to the point, where I thought about analyzing the WoW-Window and searching for a visual pattern to accomplish for what I´m looking for.
My program should check and tell me, whenever a user of the program is queuing for an battleground and should also tell me on which battleground he/she is queuing, so I can gather the data and post it to my service/website. I could create some visual feedback with an WoW-Addon, for the events I´m looking for ... like a signal, which tells my program what to do.
So I´d like to know, how I would accomplish to create such signal-interpreter( so like an Screen Grabber). I was thinking about OpenCV, but dont know where to start, especially I´m kinda curious in how Warden(Anti Cheat Engine) would interpret such program, I really don`t want my users to get banned for such a thing. It should really just interpret visual feedback of the addon I´d create.
So for example:
If user queues for Arathi Basin, a yellow signal should pop and if the yellow signal pops up, the program tells my service that player xyz has queued up, which should be displayed later on ... on my homepage in real-time. If the user queues up for Warsong, another signal pops up, etc.
I´m currently just experienced with C#/.NET in an early stage and would start a little project with such an service, so what I need to learn to get this thing build up?
I really just would love to have a little guide on which knowledge I need, to solve this problem.
for Windows it is doable but grabbing WinAPI is a bit unstable.
So write new App that:
you need to find the WoW Client window (its handle)
grab its canvas as bitmap
If gfx driver allows it if not try to take the desktop image instead. So create canvas with:
Canvas->handle = GetDC(WOW_window_handle);
its size you get like this:
RECT r; GetWindowRect(WOW_window_handle,&r);
so now just copy rectangle from canvas to your bitmap for processing ...
then you can do what ever you need to
as the image is computer generated it will not be too much noisy only scaled +/- some filters so it should be relatively easy to detect if the image contains battleground info or not. Also detect/read text in it should be easy enough
if searched event/info was detected
then just send the data to your WEB
if you need to have this info also inside the ADDON
then you need to search for some way to receive it. I am not familiar with WoW addon programming so have no clue...
but I would try:
if you got any IPC capability from Addon use it
if you have access to files
then continuosly scan a file from addon and send the info there (be careful with multiple file access conflicts)
can try to send keystrokes to your WoW client
if you can detect them from Addon or specific actions like wrote specific text message (not conflicting your movement keys)
if you can hack in your Server/Clienet TCP/IP stream
you could inject packets with specific meaning like incoming private message etc but you would need to be familiar with WoW Server/Client communication (WoW uses SRP6 if I remember correctly) and it would increase the ping lag ... You still need to be able to detect it from Addon on the other hand you should be able to detect packets related to battleground and do not need to OCR/CV the WoW image ...
see these related Q/A's:
list windows handle from outside app
simple OCR
How to recognize UI elements in image
Putting an application in between client and server ... contains example of WoW SRP6 protocol packets in mine post there
MaNGOS source repository ... can learn much about WoW from this
[Notes]
Each of the bullets is suitable for separate question so start coding and when hit a problem ask specific question about it

Prevent application from changing desktop resolution

So i have a really old game client that annoyingly takes it upon itself to change the desktop resolution to cater for something like 1600x900 resolution to achieve full screen, i'm trying to figure out how to stop this happening.
I imagine it's calling something like ChangeDisplaySettings() in user32.dll, if so is it possible to block specific dll calls, or perhaps an easier way?
Thanks in advance.
EDIT: I should add the game client is not my own thus i have no direct control over what it's doing.
I have managed to breakpoint before the ChangeDisplaySettingsA() call and modify the lpDevMode parameters to achieve what i want, now i just need to figure out how to do this programmatically.

Enabling and disabling playback and recording devices

I am a newbie in c#..Please dont get annoyed by my question if its kinda silly one..
I need to see the disabled playback and recording devices by c# code and want to enable or disable it as per my need.
How can I approach..??
I made a code using DirectX.DirectSound API but it is limited to enumerate the devices which are only enabled and i am not able see the disabled devices present. And I don't think there is any method of disabling or enabling the devices.
I'll be very thankful to u for the help.
And please also suggest me how can I do this with using other API's if possible.
I realize this is a really really old thread... but I landed here trying to find out how to list disabled audio devices, and I was successful with a C++ project called AudioEndpointController
Simply change the line:
PlaybackDevice = pEnum->EnumAudioEndpoints(eRender, DEVICE_STATE_ACTIVE, &pDevices);
to:
PlaybackDevice = pEnum->EnumAudioEndpoints(eRender, DEVICE_STATE_DISABLED, &pDevices);
As far as i know, it is not possible to programatically enable/disable devices. As for the first part of your question (need to see disabled devices), this is in fact possible but not using c# alone, you'll have to use WASAPI for this either by using C++/CLI or using explicit PInvoke in C#. You're looking for IMMDeviceEnumerator::EnumAudioEndpoints which takes a flag indicating if you want to see disabled/unplugged etc. devices. See http://msdn.microsoft.com/en-us/library/windows/desktop/dd371400%28v=vs.85%29.aspx. The nice about WASAPI's IMMDevice interface in this case is that it exposes a GUID which corresponds to the device's DirectSound id, so you can actually use WASAPI to detect which devices are active/inactive etc. and do all your other stuff using DirectSound. For this, you'll want to use IMMDevice::OpenPropertyStore, and query for the PKEY_AudioEndpoint_GUID property. This is the exact same thing that's passed in to DirectSound's DSEnumCallback function.

Make entire screen monochrome and other full screen effects

Does anyone know how to apply effects to the entire screen, in c# or any programming language.
I'm mostly interested in making the screen monochrome (specifically green-white instead of black white).
I know a cross-graphic card solution is possible because I found a program that can do it:
http://www.freedomscientific.com/products/lv/magic-bl-product-page.asp
Anyone knows how to accomplish something this or where to look?
Thanks !!
There is no easy Windows API to modify the entire screen contents. But this could be done at the device driver level.
Otherwise you have to resort to some Windows API tricks: place a "fake" window over the entire desktop, in a loop: grab the entire screen contents without grabbing fake window contents, do your processing to get the monochrome effect, then display that on the fake window. Yes, it's hacky and slow, but possible. Even more hacky, when you get mouse clicks to "go through" the fake window (lots of SetWindowsRgn calls).
So cross-platform here means using GDI, though some older DirectDraw APIs might work, in that case, you have a much easier time with hardware overlays (and better performance). Though I'm not sure how many cards actually support hardware overlays, and if newer versions of windows support the older DirectDraw APIs.
One more possibility is if the video card has a C# or C++ or C API, then you can do whatever you want with the card without writing device driver code.
Then there's CUDA, but I haven't yet tried that out. I know it's for stream processing on nVidia boards, but I wonder if it could get you an easy backdoor into the video display stuff.
To help people in the future who are interested in this:
This is possible with the Magnification API's color effect method. This allows one to use a matrix that can be applied to the whole screen.
NegativeScreen is an open source project that implements the feature you are describing in C#.
Unfortunately, this only works with affine transformations, as the API takes only an augmented matrices rather than a delegate or something.

Using webcam's button in my own program

My webcam has a button, with which you take a photo of current frame
when using it's original software what came with it when I bought it.
Is there any way to use that button to take photos in my program.
I would be using C#.
I was thinking of using Windows Image Acquisition (WIA) or avicap32
for using webcam in my software.
Any help would be appreciated. Where do I start?
EDIT:
I see that you didn't understand me. I need to know if my phisycal camera button is pressed.
I am using DigiMicro 1.3 camera (Manufacturer is DNT), which isn't really a webcam but a USB microscope, but
it behaves like a webcam.
Does the camera actually require that the software be running when you press the button? I know some webcams implement this feature at the driver level. If that's the case, I don't think there's much you can do without interacting directly with the USB port, which would be incredibly difficult and likely not worth the trouble. I can't find any technical documentation on the vendor's website with that kind of information.
The "MicroCapture" software doesn't come with any DLLs that have exported functions, so P/Invoking doesn't appear to be an option. Unfortunately, I can't get the driver installed, so I can't check if it comes with any P/Invoke-able DLLs.
Sorry, but since there's no standard interface for that kind of functionality and the vendor doesn't provide any specific information on it, I don't think this is possible. I would suggest contacting DNT directly about it. They may have some component that will do what you need.
This Coding4Fun post guides you through pretty much everything you need to do to get started using WIA, including adding the reference to a project, displaying the select a device dialog, and of course actually taking the picture :P.
Coding4Fun - Look at me! Windows Image Acquisition
I suggest that you take a look at the DirectShow.NET library. It has great functionality for capturing images/videos off connected devices. It also comes with several samples to get you started quickly.

Categories