Comments (7)
Hello, thank you for your question.
Do you need to use DirectShow filter?
My suggestion is, how about change bitmap's brightness after GetBitmap() from UsbCamera.
See example below.
private void Form_Load(object sender, EventArgs e)
{
var camera = new GitHub.secile.Video.UsbCamera(0, new Size(640, 480));
camera.Start();
// trackBar1 value range is -100 to +100.
float brightness_offset = 0;
trackBar1.ValueChanged += (s, ev) => brightness_offset = trackBar1.Value / 100f;
var timer = new System.Timers.Timer(100);
timer.Elapsed += (s, ev) =>
{
var bmp = camera.GetBitmap();
bmp = ChangeBitmapBrightness(bmp, brightness_offset);
pbxScreen.Image = bmp;
};
timer.Start();
this.FormClosing += (s, ev) =>
{
camera.Stop();
};
}
// offset value range is -1 to +1.
// -1 becomes src image black out.
// +1 becomes src image white out.
// 0 do nothing.
private Bitmap ChangeBitmapBrightness(Bitmap src, float offset)
{
var matrix = new System.Drawing.Imaging.ColorMatrix()
{
Matrix00 = 1, Matrix11 = 1, Matrix22 = 1, Matrix33 = 1, Matrix44 = 1,
Matrix40 = offset, // r
Matrix41 = offset, // g
Matrix42 = offset, // b
};
var attribute = new System.Drawing.Imaging.ImageAttributes();
attribute.SetColorMatrix(matrix);
var result = new Bitmap(src.Width, src.Height);
using (var g = Graphics.FromImage(result))
{
g.DrawImage(src, new Rectangle(Point.Empty, src.Size), 0, 0, src.Width, src.Height, GraphicsUnit.Pixel, attribute);
}
return result;
}
from usbcamera.
But does this work if another application is already using the camera? I need to be able to "black out" the camera for every application on the computer.
from usbcamera.
Oh I see. It can not work.
I would like to confirm. Does another application means application that uses this UsbCamera library? or the application like camera app on Windows10?
from usbcamera.
I mean any other application for example Zoom, Skype, Discord etc. I had decent success with setting the camera's brightness to zero but it does only work on some cameras.
from usbcamera.
Thank you for your information.
In my understandings, if you insert DirectShow filter, do not make effect to another application. Because each application make it's own DirectShow filter graph. The change of filter graph make effect to your application only.
from usbcamera.
Ok thank you very much for you information and time. That would mean the best way would be a virtual camera device, which usually just passes the original camera through but can interrupt this stream to black the camera out. Is it possible to write this in C# or do I have to do is in C++?
from usbcamera.
I think using virtual camera is good idea. To make virtual camera, you have to create DirectShow video capture source filter in C++. Making DirectShow filter has some complex steps... so please google.
I have ever been used following source code called 'ycapture' to make Virtual Camera. (no english, sorry)
http://yzwlab.net/ycapture/
If you are going to use ycapture, I can share you how to send image to ycapture from your application.
from usbcamera.
Related Issues (20)
- Setting gain and exposure time HOT 1
- Expand camera image HOT 15
- Insufficient system resources HOT 1
- Camera preview locked HOT 14
- It is better do not enter critical section in callback function. HOT 1
- Memory leak HOT 3
- On Capture Callback HOT 5
- much more latency than amcap HOT 1
- WPF 每次 BufferToBitmap 的时候都创建新的 WriteableBitmap 岂不是完全没发挥 WriteableBitmap 的性能 HOT 11
- Release taking long time sometimes HOT 1
- How can I get the datas of every frame? HOT 9
- missing events HOT 4
- How can I switch camera? HOT 2
- provide nuget package HOT 4
- Implement IDisposable / IObservable pattern HOT 1
- 需要增加对于部分非标的虚拟摄像头的过滤(It is necessary to increase the filtering of some non-standard virtual cameras) HOT 7
- Problem with showing preview HOT 4
- Camera preset HOT 7
- Can you make the class public? HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from usbcamera.