using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using AForge;
using AForge.Video;
using AForge.Video.DirectShow;
namespace Sample
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private FilterInfoCollection CaptureDevice;
private VideoCaptureDevice FinalFrame;
private void Form1_Load(object sender, EventArgs e)
{
CaptureDevice = new FilterInfoCollection(FilterCategory.AudioCompressorCategory);
foreach (FilterInfo Device in CaptureDevice)
{
comboBox1.Items.Add(Device.Name);
}
comboBox1.SelectedIndex = 0;
FinalFrame = new VideoCaptureDevice();
}
private void button1_Click(object sender, EventArgs e)
{
FinalFrame = new VideoCaptureDevice(CaptureDevice[comboBox1.SelectedIndex].MonikerString);
FinalFrame.NewFrame+= new NewFrameEventHandler (FinalFrame_NewFrame);
FinalFrame.Start();
}
private void FinalFrame_NewFrame(object sender, NewFrameEventArgs eventArgs)
{
pictureBox1.Image = (Bitmap)eventArgs.Frame.Clone();
}
}
}
This code is used to getting for open my web camera, this code is worked properly. I want to add a little code part to convert REAL TIME VIDEO into GRAY-SCALE VIDEO, if anyone knows the algorithm, Please help me to do that.
Related
I am currently using WinForms Application and it seems that I have ran into a problem. I have a button that when pressed it outputs a link in a RichTextBox. However, the link is highlighted in blue but when I click it does not open in my browser. Here is the code(Note that https://something.com/ represents an actual link.):
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Project
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
richTextBox1.Text = "https://something.com/" + textBox1.Text;
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
}
}
}
as title, i have a button that load an image in a picturebox, then when i click on it i want it to display the coordinates in two textbox, only proble...it display the coordinates when i click outside of the picturebox and not when i click in.
i already tried the solution in this site but it doesn't seems to work so far.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
protected override void OnMouseClick(MouseEventArgs e)
{
base.OnMouseClick(e);
textBox1.Text = e.X.ToString();
textBox2.Text = e.Y.ToString();
}
private void BtnBrowse_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "All jpg files (*.jpg)|*.jpg";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
pictureBox1.ImageLocation = openFileDialog1.FileName;
}
}
}
}
I'm trying to create program which display video from IP Camera.
This is my code :
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Emgu.CV; //
using Emgu.CV.CvEnum; // usual Emgu Cv imports
using Emgu.CV.Structure; //
using Emgu.CV.UI;
using System.IO;
using System.Reflection;
using System.Windows;
using System.Runtime.InteropServices;
using Emgu.Util;
using System.Net;
namespace WindowsFormsApplication1
{
public partial class Main : Form
{
public Main()
{
InitializeComponent();
}
public Capture _capture;
public Mat imgOriginal;
private void imageBox2_Click(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
public void button1_Click(object sender, EventArgs e)
{
_capture = new Capture("http://192.168.1.148:8080/video");
_capture.ImageGrabbed += ProcessFrame;
_capture.Start();
}
public void ProcessFrame(object sender, EventArgs arg)
{
imgOriginal= _capture.QueryFrame();
ibOriginal.Image = imgOriginal;
}
}
}
It's getting stuck on this step (without expectation):
imgOriginal= _capture.QueryFrame();
Maybe i should you invoke method but i don't know how.
Im using Emgu 3.1.0 Link to Doc
I managed to troubleshoot this . I made some canonical and syntax mistakes.
I provide working code for community:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Emgu.CV; //
using Emgu.CV.CvEnum; // usual Emgu Cv imports
using Emgu.CV.Structure; //
using Emgu.CV.UI;
using System.IO;
using System.Reflection;
using System.Windows;
using System.Runtime.InteropServices;
using Emgu.Util;
using System.Net;
namespace WindowsFormsApplication1
{
public partial class Main : Form
{
public Main()
{
InitializeComponent();
Run();
}
public Capture _capture;
public Mat imgOriginal;
private void imageBox2_Click(object sender, EventArgs e)
{
}
private void label1_Click(object sender, EventArgs e)
{
}
void Run()
{
try
{
_capture = new Capture("http://192.168.1.148:8080/video");
}
catch (Exception e)
{
MessageBox.Show(e.Message);
return;
}
Application.Idle += ProcessFrame;
}
void ProcessFrame(object sender, EventArgs e)
{
Mat frame = _capture.QueryFrame();
ibOriginal.Image = frame;
}
public void button1_Click(object sender, EventArgs e)
{
}
}
}
I use fallowing library to detect webcam for simple c# application. When it debug works fine and when I try again It give fallowing error.
Used reference
If somebody has any idea about it please help me to solve it.
First get this box and when click OK get fallowing error message.
an error occurred while capturing the video image. the video capture
will now be terminated. Object reference not set to an instance of an
object.
Form1.cs
using System;
using System.Linq;
using System.Text;
using System.Data;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel;
using System.Collections.Generic;
using WinFormCharpWebCam;
namespace camTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
WebCam webcam;
private void button1_Click(object sender, EventArgs e)
{
webcam.Start();
}
private void button2_Click(object sender, EventArgs e)
{
webcam.Stop();
}
private void button3_Click(object sender, EventArgs e)
{
webcam.Continue();
}
private void Form1_Load(object sender, EventArgs e)
{
webcam = new WebCam();
webcam.InitializeWebCam(ref imgVideo);
}
}
}
Webcam.cs
using System;
using System.IO;
using System.Linq;
using System.Text;
using WebCam_Capture;
using System.Collections.Generic;
namespace WinFormCharpWebCam
{
//Design by Pongsakorn Poosankam
class WebCam
{
private WebCamCapture webcam;
private System.Windows.Forms.PictureBox _FrameImage;
private int FrameNumber = 30;
public void InitializeWebCam(ref System.Windows.Forms.PictureBox ImageControl)
{
webcam = new WebCamCapture();
webcam.FrameNumber = ((ulong)(0ul));
webcam.TimeToCapture_milliseconds = FrameNumber;
webcam.ImageCaptured += new WebCamCapture.WebCamEventHandler(webcam_ImageCaptured);
_FrameImage = ImageControl;
}
void webcam_ImageCaptured(object source, WebcamEventArgs e)
{
_FrameImage.Image = e.WebCamImage;
}
public void Start()
{
webcam.TimeToCapture_milliseconds = FrameNumber;
webcam.Start(0);
}
public void Stop()
{
webcam.Stop();
}
public void Continue()
{
// change the capture time frame
webcam.TimeToCapture_milliseconds = FrameNumber;
// resume the video capture from the stop
webcam.Start(this.webcam.FrameNumber);
}
public void ResolutionSetting()
{
webcam.Config();
}
public void AdvanceSetting()
{
webcam.Config2();
}
}
}
I have a C# Web Browser, I am trying to access: my.screenname.aol.com for mail, but it won't even load, I don't have much code...as you can see:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace EmailViewer
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
timer1.Enabled = true;
}
private void timer1_Tick(object sender, EventArgs e)
{
timer1.Enabled = false;
webBrowser1.Navigate("my.screenname.aol.com");
}
}
}
It's worth a shot to try WebBrowser.ScriptErrorsSuppressed Property to true.