asp.net wpf Aforge get edge points

Source: Internet
Author: User

Recently contacted projects, using a large number of pictures and video operations, where the use of WPF Aforge encountered many problems. This site will slowly share with you

1, Get edge point method:

<summary>
The more edge points, the clearer the image
</summary>
<param name= "source" ></param>
<returns></returns>
public int Get Edge point number (System.Drawing.Bitmap source)
{
Try
{
AForge.Imaging.SusanCornersDetector mcd = new AForge.Imaging.SusanCornersDetector ();
List<aforge.intpoint> Corners = mcd. Processimage (source);
Return corners. Count ();
}
Catch
{
AForge.Imaging.MoravecCornersDetector mcd = new AForge.Imaging.MoravecCornersDetector ();
List<aforge.intpoint> Corners = mcd. Processimage (source);
Return corners. Count ();
}
}
2, the use of aforge with the dynamic video display video

<summary>
Load Default Device
</summary>
public void Cameraopen ()
{

Closecapturedevice ();
Set the initial video device
Filterinfocollection videodevices = new Filterinfocollection (filtercategory.videoinputdevice);
if (Videodevices.count > 0)
{
for (int i = 0; i < Videodevices.count; i++)
{
if (videodevices[i). Name.indexof ("YW") >-1)
{
Devicemoniker = Videodevices[i]. monikerstring;
Break
}
}
Devicemoniker = Videodevices[0]. Name.contains ("YW"). monikerstring;
Usbvideo = new Videocapturedevice (videodevices[0). monikerstring);
Camera_Chemistry.vp.videoMonkeyName = Videodevices[0]. monikerstring;
Usbvideo = new Videocapturedevice (devicemoniker);
Camera_Chemistry.vp.videoMonkeyName = Devicemoniker;
Sourceplayer.newframe-= new AForge.Controls.VideoSourcePlayer.NewFrameHandler (videosourceplayer_newframe);
Sourceplayer.newframe + = new AForge.Controls.VideoSourcePlayer.NewFrameHandler (videosourceplayer_newframe);
Usbvideo.videoresolution = UsbVideo.VideoCapabilities.Where (a => a.framesize.width = = 640 && A. Framesize.height = 480). FirstOrDefault ();
Usbvideo.snapshotframe + = Usbvideo_snapshotframe;
Usbvideo.newframe + = Usbvideo_newframe; Screenshots
Sourceplayer.videosource = Usbvideo;
Sourceplayer.start ();
}
Else
{
button_play.isenabled = false;
button_capture.isenabled = false;
}
Set the camera's properties, brightness contrast
Gaobeijingcamera ();
This motor state = 1; 5
}

private void Closecapturedevice ()
{
if (Sourceplayer!= null && sourceplayer.videosource!= null)
{
if (sourceplayer.isrunning)
{
Sourceplayer.signaltostop ();
Sourceplayer.waitforstop ();
Sourceplayer.stop ();
}
Sourceplayer.videosource = null;
if (usbvideo.providesnapshots)
{
Usbvideo.snapshotframe-= new Newframeeventhandler (usbvideo_snapshotframe);
}
}
}
Get Pictures:

private void Usbvideo_newframe (object sender, Newframeeventargs eventArgs)
         {
           //Showsnapshot ( SYSTEM.DRAWING.BITMAP) eventargs.frame); //. Clone ()
            showsnapshot (EventArgs);
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.