|
|
@ -56,6 +56,8 @@ namespace Emgu.CV.Example.Mac |
|
|
|
} |
|
|
|
|
|
|
|
void RunDetectFace() |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
//Read the files as an 8-bit Bgr image
|
|
|
|
NSImage nsImage = NSImage.ImageNamed("lena.jpg"); |
|
|
@ -77,6 +79,14 @@ namespace Emgu.CV.Example.Mac |
|
|
|
CvInvoke.Rectangle(image, eye, new Bgr(Color.Blue).MCvScalar, 2); |
|
|
|
|
|
|
|
mainImageView.Image = image.ToNSImage(); |
|
|
|
} catch (Exception e) |
|
|
|
{ |
|
|
|
InvokeOnMainThread(() => |
|
|
|
{ |
|
|
|
messageLabel.StringValue = e.Message; |
|
|
|
messageLabel.InvalidateIntrinsicContentSize(); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void RunFeatureMatching() |
|
|
@ -119,7 +129,7 @@ namespace Emgu.CV.Example.Mac |
|
|
|
|
|
|
|
private void ProcessFrame(object sender, EventArgs arg) |
|
|
|
{ |
|
|
|
if (_capture != null && _capture.Ptr != IntPtr.Zero) |
|
|
|
if (_capture != null && _capture.Ptr != IntPtr.Zero && _capture.IsOpened) |
|
|
|
{ |
|
|
|
_capture.Retrieve(_frame, 0); |
|
|
|
var nsImage = _frame.ToNSImage(); |
|
|
@ -137,11 +147,11 @@ namespace Emgu.CV.Example.Mac |
|
|
|
_capture = new VideoCapture(); |
|
|
|
if (_capture == null || !_capture.IsOpened) |
|
|
|
{ |
|
|
|
_capture = null; |
|
|
|
InvokeOnMainThread(() => |
|
|
|
{ |
|
|
|
messageLabel.StringValue = "unable to create capture"; |
|
|
|
}); |
|
|
|
_capture = null; |
|
|
|
return; |
|
|
|
} |
|
|
|
_capture.ImageGrabbed += ProcessFrame; |
|
|
|