Start with the following:
------------------------------- The following procedure is recorded :------------------------------------------------------
- Download the "wpfmediakit. dll" program and use it in the project to add references;
- Introduce and name xmlns: wpfmedia = "CLR-namespace: wpfmediakit. DirectShow. controls; Assembly = wpfmediakit" in the WPF window"
- Use a videocaptureelement control on the interface:
- When loading the camera device in the window and selecting the camera switch, the device source of the interface control also changes:
- Click "Take photo" and "confirm code":
1 // define an attribute 2 Public byte [] capturedata {Get; set ;} 3 4 /// <summary> 5 // click "photo" 6 /// </Summary> 7 private void btncapture_click (Object sender, routedeventargs E) 8 {9 rendertargetbitmap BMP = new rendertargetbitmap (INT) captureelement. actualwidth, (INT) captureelement. actualheight, 10 96,96, pixelformats. default); 11 BMP. render (captureelement); 12 bitmapencoder encoder = new encode bitmapencoder (); 13 encoder. frames. add (bitmapframe. create (BMP); 14 using (memorystream MS = new memorystream () 15 {16 encoder. save (MS); 17 capturedata = Ms. toarray (); // Save the photo to attributes 18} 19 captureelement. pause (); 20} 21 // click OK 22 private void btnok_click (Object sender, routedeventargs e) 23 {24 dialogresult = true; 25}View code