Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 4th, 2012  |  syntax: None  |  size: 1.82 KB  |  hits: 41  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. EmguCV 2.3.0 in C# QueryFrame returns the previous queried frame
  2. _capture = new Capture();
  3. Image<Bgr, Byte> frame = _capture.QueryFrame();
  4.  
  5. Image<Gray, Byte> grayFrame = frame.Convert<Gray, Byte>();
  6. Image<Gray, Byte> smallGrayFrame = grayFrame.PyrDown();
  7. Image<Gray, Byte> smoothedGrayFrame = smallGrayFrame.PyrUp();
  8. Image<Gray, Byte> cannyFrame = smoothedGrayFrame.Canny(new Gray(100), new Gray(60));
  9.  
  10. captureImageBox.Image = frame;
  11. grayscaleImageBox.Image = grayFrame;
  12. smoothedGrayscaleImageBox.Image = smoothedGrayFrame;
  13. cannyImageBox.Image = cannyFrame;
  14. _capture.Dispose();
  15.        
  16. Image<Bgr, Byte> frame;
  17. using (Capture capture = new Capture())
  18. {
  19.     frame = capture1.QueryFrame().Copy(); //You must copy else frame will be disposed off
  20. }
  21. Image<Gray, Byte> grayFrame = frame.Convert<Gray, Byte>();
  22. Image<Gray, Byte> smallGrayFrame = grayFrame.PyrDown();
  23. Image<Gray, Byte> smoothedGrayFrame = smallGrayFrame.PyrUp();
  24. Image<Gray, Byte> cannyFrame = smoothedGrayFrame.Canny(new Gray(100), new Gray(60));
  25.  
  26. grayscaleImageBox.Image = grayFrame;
  27. smoothedGrayscaleImageBox.Image = smoothedGrayFrame;
  28. cannyImageBox.Image = cannyFrame;
  29.        
  30. Image<Bgr, Byte> frame;
  31. using (Capture capture1 = new Capture())
  32. {
  33.     frame = capture1.QueryFrame().Resize(0.5, Emgu.CV.CvEnum.INTER.CV_INTER_AREA).Copy();
  34.     captureImageBox.Image = frame;
  35. }
  36.  
  37. using (Image<Gray, Byte> grayFrame = frame.Convert<Gray, Byte>())
  38. {
  39.     grayscaleImageBox.Image = grayFrame;
  40.     using (Image<Gray, Byte> smallGrayFrame = grayFrame.PyrDown())
  41.     {
  42.         using (Image<Gray, Byte> smoothedGrayFrame = smallGrayFrame.PyrUp())
  43.         {
  44.             smoothedGrayscaleImageBox.Image = smoothedGrayFrame;
  45.             using (Image<Gray, Byte> cannyFrame = smoothedGrayFrame.Canny(new Gray(100), new Gray(60)))
  46.             {
  47.                 cannyImageBox.Image = cannyFrame;
  48.             }
  49.         }
  50.     }
  51. }