diff --git a/.gitmodules b/.gitmodules
index 15f2461d3..a14b036f3 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -21,6 +21,7 @@
[submodule "Emgu.CV.Extern/tesseract/libtesseract/leptonica/leptonica.git"]
path = Emgu.CV.Extern/tesseract/libtesseract/leptonica/leptonica.git
url = https://github.com/emgucv/leptonica.git
+ ignore = dirty
[submodule "freetype2"]
path = freetype2
url = git://git.sv.nongnu.org/freetype/freetype2.git
diff --git a/Emgu.CV.Example/XamarinForms/iOS/Emgu.CV.XamarinForms.iOS.csproj b/Emgu.CV.Example/XamarinForms/iOS/Emgu.CV.XamarinForms.iOS.csproj
index d0dd88a40..8dd458cca 100644
--- a/Emgu.CV.Example/XamarinForms/iOS/Emgu.CV.XamarinForms.iOS.csproj
+++ b/Emgu.CV.Example/XamarinForms/iOS/Emgu.CV.XamarinForms.iOS.csproj
@@ -126,12 +126,6 @@
-
-
- {0EE2B36C-F7CD-49FA-A270-D7D988CFF6E5}
- Emgu.CV.World.IOS
-
-
haarcascade_eye.xml
@@ -163,9 +157,15 @@
4.0.1.5
- 4.3.0.947036
+ 4.3.0.991211
+
+
+ {0EE2B36C-F7CD-49FA-A270-D7D988CFF6E5}
+ Emgu.CV.World.IOS
+
+
\ No newline at end of file
diff --git a/Emgu.CV.NativeImage/CGImageExtension.cs b/Emgu.CV.NativeImage/CGImageExtension.cs
index e67ca5579..1ac283424 100644
--- a/Emgu.CV.NativeImage/CGImageExtension.cs
+++ b/Emgu.CV.NativeImage/CGImageExtension.cs
@@ -31,8 +31,8 @@ namespace Emgu.CV
///
/// Copy the data from the CGImage to the current Image object
///
- private static void ImageFromCGImage(Image image, CGImage cgImage)
- where TColor : struct, IColor
+ internal static void ImageFromCGImage(Image image, CGImage cgImage)
+ where TColor : struct, IColor
where TDepth : new()
{
//Don't do this, Xamarin.iOS won't be able to resolve: if (this is Image)
@@ -89,7 +89,7 @@ namespace Emgu.CV
}
}
- private static void ConvertCGImageToArray(CGImage cgImage, IOutputArray mat, ImreadModes modes = ImreadModes.AnyColor)
+ internal static void ConvertCGImageToArray(CGImage cgImage, IOutputArray mat, ImreadModes modes = ImreadModes.AnyColor)
{
Size sz = new Size((int)cgImage.Width, (int)cgImage.Height);
using (Mat m = new Mat(sz, DepthType.Cv8U, 4))
diff --git a/Emgu.CV.NativeImage/UIImageExtension.cs b/Emgu.CV.NativeImage/UIImageExtension.cs
new file mode 100644
index 000000000..774e3abbe
--- /dev/null
+++ b/Emgu.CV.NativeImage/UIImageExtension.cs
@@ -0,0 +1,93 @@
+//----------------------------------------------------------------------------
+// Copyright (C) 2004-2019 by EMGU Corporation. All rights reserved.
+//----------------------------------------------------------------------------
+
+#if __IOS__
+using System;
+using System.Drawing;
+using Emgu.CV;
+using Emgu.CV.CvEnum;
+using Emgu.CV.Structure;
+using CoreGraphics;
+using UIKit;
+
+namespace Emgu.CV
+{
+ public static class UIImageExtension
+ {
+ ///
+ /// Creating an Image from the UIImage
+ ///
+ public static Image ToImage (this UIImage uiImage)
+ where TColor : struct, IColor
+ where TDepth : new()
+ //: this( (int) uiImage.Size.Width, (int) uiImage.Size.Height)
+ {
+ using (CGImage cgImage = uiImage.CGImage) {
+ return cgImage.ToImage ();
+ }
+ }
+
+ ///
+ /// Convert this Image object to UIImage
+ ///
+ public static UIImage ToUIImage (this Image image)
+ where TColor : struct, IColor
+ where TDepth : new()
+ {
+ using (CGImage cgImage = image.ToCGImage ()) {
+ return UIImage.FromImage (cgImage);
+ }
+ }
+
+ ///
+ /// Initializes a new instance of the class from UIImage
+ ///
+ /// The color conversion mode. By default, it convert the UIImage to BGRA color type to preserve all the image channels.
+ /// The UIImage.
+ public static UMat ToUMat(this UIImage uiImage, ImreadModes mode = ImreadModes.AnyColor)
+ {
+ //UMat umat = new UMat ();
+ using (CGImage cgImage = uiImage.CGImage) {
+ //ConvertCGImageToArray (cgImage, this, mode);
+ return cgImage.ToUMat (mode);
+ }
+ }
+
+ ///
+ /// Converts to UIImage.
+ ///
+ /// The UIImage.
+ public static UIImage ToUIImage (this UMat umat)
+ {
+ using (CGImage tmp = umat.ToCGImage ()) {
+ return UIImage.FromImage (tmp);
+ }
+ }
+
+ ///
+ /// Initializes a new instance of the class from UIImage
+ ///
+ /// The color conversion mode. By default, it convert the UIImage to BGRA color type to preserve all the image channels.
+ /// The UIImage.
+ public static Mat ToMat(this UIImage uiImage, ImreadModes mode = ImreadModes.AnyColor)
+ {
+ using (CGImage cgImage = uiImage.CGImage) {
+ return cgImage.ToMat (mode);
+ }
+ }
+
+ ///
+ /// Converts to UIImage.
+ ///
+ /// The UIImage.
+ public static UIImage ToUIImage (this Mat mat)
+ {
+ using (CGImage tmp = mat.ToCGImage ()) {
+ return UIImage.FromImage (tmp);
+ }
+ }
+ }
+}
+
+#endif
\ No newline at end of file
diff --git a/Emgu.CV.World/ApiDefinition.cs b/Emgu.CV.World/iOS/ApiDefinition.cs
similarity index 100%
rename from Emgu.CV.World/ApiDefinition.cs
rename to Emgu.CV.World/iOS/ApiDefinition.cs
diff --git a/Emgu.CV.World/Emgu.CV.World.IOS.csproj b/Emgu.CV.World/iOS/Emgu.CV.World.IOS.csproj
similarity index 64%
rename from Emgu.CV.World/Emgu.CV.World.IOS.csproj
rename to Emgu.CV.World/iOS/Emgu.CV.World.IOS.csproj
index dd30b4f04..753910bc0 100644
--- a/Emgu.CV.World/Emgu.CV.World.IOS.csproj
+++ b/Emgu.CV.World/iOS/Emgu.CV.World.IOS.csproj
@@ -6,10 +6,13 @@
{8FFB629D-F513-41CE-95D2-7ECE97B6EEEC};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
{0EE2B36C-F7CD-49FA-A270-D7D988CFF6E5}
Library
- Emgu.CV.World.IOS
+ Emgu.CV
Resources
Emgu.CV.World.IOS
+
+ $(MSBuildThisFileDirectory)..\..\libs
+
true
full
@@ -32,7 +35,6 @@
true
$(OutputPath)$(AssemblyName).xml
-
@@ -48,19 +50,41 @@
$(TargetFrameworkRootPath)\Xamarin.iOS\v1.0\Facades\System.Drawing.Common.dll
+
+ Xamarin iOS Native Binding Library
+ $(OpenCVBinaryDir)\iOS\libcvextern.a
+ This package do not contain necessary binary for $(EmguCVLinkTarget). Emgu CV for iOS Commercial License is required. Missing $(EmguCVNativeFile)
+ $(EmguCVDeployMessage)ios
+ $(MSBuildThisFileDirectory)\libcvextern.linkwith.cs
+ This package do not contain necessary file for $(EmguCVLinkTarget). Emgu CV for iOS Commercial License is required. Missing $(EmguCVLinkWithFile)
+
+
+
+
+
+
+ libcvextern.a
+
+
+
+ CGImageExtension.cs
+
+
+ UIImageExtension.cs
+
-
-
-
-
+
+
+
+
@@ -71,4 +95,4 @@
-
\ No newline at end of file
+
diff --git a/Emgu.CV.World/iOS/Properties/AssemblyInfo.cs b/Emgu.CV.World/iOS/Properties/AssemblyInfo.cs
new file mode 100644
index 000000000..6946a7100
--- /dev/null
+++ b/Emgu.CV.World/iOS/Properties/AssemblyInfo.cs
@@ -0,0 +1,16 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+// Information about this assembly is defined by the following attributes.
+// Change them to the values specific to your project.
+
+[assembly: AssemblyTitle("Emgu.CV.World")]
+[assembly: AssemblyDescription("")]
+
+
+
+// The following attributes are used to specify the signing key for the assembly,
+// if desired. See the Mono documentation for more information about signing.
+
+//[assembly: AssemblyDelaySign(false)]
+//[assembly: AssemblyKeyFile("")]
diff --git a/Emgu.CV/PInvoke/iOS/libcvextern.linkwith.cs b/Emgu.CV.World/iOS/libcvextern.linkwith.cs
similarity index 100%
rename from Emgu.CV/PInvoke/iOS/libcvextern.linkwith.cs
rename to Emgu.CV.World/iOS/libcvextern.linkwith.cs
diff --git a/Emgu.CV/Core/Image.cs b/Emgu.CV/Core/Image.cs
index 6be1e2e5b..dcc214939 100644
--- a/Emgu.CV/Core/Image.cs
+++ b/Emgu.CV/Core/Image.cs
@@ -148,7 +148,7 @@ namespace Emgu.CV
using (CGImage tmp = CGImage.FromPNG(provider, null, false, CGColorRenderingIntent.Default))
{
AllocateData((int)tmp.Height, (int)tmp.Width, NumberOfChannels);
- ConvertFromCGImage(tmp);
+ CGImageExtension.ImageFromCGImage (this, tmp);
}
return;
}
@@ -219,7 +219,7 @@ namespace Emgu.CV
using (UIImage tmp = UIImage.FromFile(fileName))
{
AllocateData((int)tmp.Size.Height, (int)tmp.Size.Width, NumberOfChannels);
- ConvertFromCGImage(tmp.CGImage);
+ CGImageExtension.ImageFromCGImage(this, tmp.CGImage);
}
#elif __UNIFIED__
#else
diff --git a/Emgu.CV/Core/Mat.cs b/Emgu.CV/Core/Mat.cs
index db8637459..332f60831 100644
--- a/Emgu.CV/Core/Mat.cs
+++ b/Emgu.CV/Core/Mat.cs
@@ -250,7 +250,7 @@ namespace Emgu.CV
using (CGDataProvider provider = new CGDataProvider(fileName))
using (CGImage tmp = CGImage.FromPNG(provider, null, false, CGColorRenderingIntent.Default))
{
- CvInvoke.ConvertCGImageToArray(tmp, this, loadType);
+ CGImageExtension.ConvertCGImageToArray(tmp, this, loadType);
}
return;
}
@@ -276,7 +276,7 @@ namespace Emgu.CV
//try again to load with UIImage
using (UIImage tmp = UIImage.FromFile(fileName))
{
- CvInvoke.ConvertCGImageToArray(tmp.CGImage, this);
+ CGImageExtension.ConvertCGImageToArray(tmp.CGImage, this);
}
#else
throw new ArgumentException(String.Format("Unable to decode file: {0}", fileName));
diff --git a/Emgu.CV/Emgu.CV.projitems b/Emgu.CV/Emgu.CV.projitems
index ade70628d..5c075ea83 100644
--- a/Emgu.CV/Emgu.CV.projitems
+++ b/Emgu.CV/Emgu.CV.projitems
@@ -40,155 +40,5 @@
-
-
-
-
- $(MSBuildThisFileDirectory)..\libs
- $(MSBuildThisFileDirectory)
-
-
-
-
-
-
- Xamarin iOS Native Binding Library
- $(OpenCVBinaryDir)\iOS\libcvextern.a
- This package do not contain necessary binary for $(EmguCVLinkTarget). Emgu CV for iOS Commercial License is required. Missing $(EmguCVNativeFile)
- $(EmguCVDeployMessage)ios
- $(EmguCVDir)PInvoke\iOS\libcvextern.linkwith.cs
- This package do not contain necessary file for $(EmguCVLinkTarget). Emgu CV for iOS Commercial License is required. Missing $(EmguCVLinkWithFile)
-
-
-
-
-
-
- libcvextern.a
-
-
-
-
-
-
- Xamarin.Mac
- $(OpenCVBinaryDir)\osx\libcvextern.dylib
- This package do not contain necessary binary for $(EmguCVLinkTarget). Emgu CV for Mac Commercial License is required. Missing $(EmguCVNativeFile)
- $(EmguCVDeployMessage)mac
-
-
-
- Dynamic
- False
-
-
-
-
-
-
- Direct reference of Emgu CV for Xamarin iOS is only available with Xamarin Studio on Mac. When using Emgu CV in Visual Studio with Xamarin iOS plug in, please add the Emgu.CV.iOS.World reference instead.
- Xamarin iOS App
- $(OpenCVBinaryDir)\iOS\libcvextern.a
- This package do not contain necessary binary for $(EmguCVLinkTarget). Emgu CV for iOS Commercial License is required. Missing $(EmguCVNativeFile)
- $(MtouchExtraArgs) -cxx -gcc_flags "-L$(OpenCVBinaryDir)\iOS\ -lcvextern -force_load $(OpenCVBinaryDir)\iOS\libcvextern.a -framework Foundation -framework Accelerate -framework CoreFoundation -framework CoreGraphics -framework AssetsLibrary -framework AVFoundation -framework CoreImage -framework CoreMedia -framework CoreVideo -framework QuartzCore -framework ImageIO -framework UIKit"
- $(EmguCVDeployMessage)ios
-
-
-
-
-
- Xamarin Android App
- Xamarin Android Library
-
- $(OpenCVBinaryDir)\android\armeabi-v7a\libcvextern.so
- True
- This package do not contain necessary binary for $(EmguCVLinkTarget). Emgu CV for Android Commercial License is required. Armeabi-v7a is targeted, but file $(EmguCVNativeArmeabiv7a) is missing.
- $(EmguCVDeployMessage)armeabi-v7a
- $(OpenCVBinaryDir)\android\arm64-v8a\libcvextern.so
- True
- This package do not contain necessary binary for $(EmguCVLinkTarget). Emgu CV for Android Commercial License is required. Arm64-v8a is targeted, but file $(EmguCVNativeArm64v8a) is missing.
- $(EmguCVDeployMessage)arm64-v8a
- $(OpenCVBinaryDir)\android\x86\libcvextern.so
- True
- This package do not contain necessary binary for $(EmguCVLinkTarget). Emgu CV for Android Commercial License is required. x86 is targeted, but file $(EmguCVNativex86) is missing.
- $(EmguCVDeployMessage)x86
- $(OpenCVBinaryDir)\android\x86_64\libcvextern.so
- True
- This package do not contain necessary binary for $(EmguCVLinkTarget). Emgu CV for Android Commercial License is required. x86_64 is targeted, but file $(EmguCVNativex8664) is missing.
- $(EmguCVDeployMessage)x86_64
-
-
-
-
-
-
- lib\armeabi-v7a\libcvextern.so
-
-
- lib\armeabi-v7a\libcvextern.so
-
-
-
-
-
- lib\arm64-v8a\libcvextern.so
-
-
- lib\arm64-v8a\libcvextern.so
-
-
-
-
-
- lib\x86\libcvextern.so
-
-
- lib\x86\libcvextern.so
-
-
-
-
-
- lib\x86_64\libcvextern.so
-
-
- lib\x86_64\libcvextern.so
-
-
-
-
-
-
- DotNetCore
-
-
-
-
-
- NetStandard
-
-
-
-
-
-
-
-
-
-
diff --git a/Emgu.CV/PInvoke/iOS/ImageiOS.cs b/Emgu.CV/PInvoke/iOS/ImageiOS.cs
deleted file mode 100644
index 58243dfbc..000000000
--- a/Emgu.CV/PInvoke/iOS/ImageiOS.cs
+++ /dev/null
@@ -1,109 +0,0 @@
-//----------------------------------------------------------------------------
-// Copyright (C) 2004-2019 by EMGU Corporation. All rights reserved.
-//----------------------------------------------------------------------------
-
-#if __IOS__
-using System;
-using System.Drawing;
-using Emgu.CV;
-using Emgu.CV.Structure;
-using CoreGraphics;
-using UIKit;
-
-namespace Emgu.CV
-{
- public partial class Image
- : CvArray, IEquatable>
- where TColor : struct, IColor
- where TDepth : new()
- {
- ///
- /// Creating an Image from the CGImage
- ///
- public Image(CGImage cgImage)
- : this( (int) cgImage.Width, (int) cgImage.Height)
- {
- ConvertFromCGImage(cgImage);
- }
-
- ///
- /// Copy the data from the CGImage to the current Image object
- ///
- private void ConvertFromCGImage(CGImage cgImage)
- {
- //Don't do this, Xamarin.iOS won't be able to resolve: if (this is Image)
- if (typeof(TColor) == typeof(Rgba) && typeof(TDepth) == typeof(byte))
- {
- RectangleF rect = new RectangleF(PointF.Empty, new SizeF(cgImage.Width, cgImage.Height));
- using (CGColorSpace cspace = CGColorSpace.CreateDeviceRGB())
- using (CGBitmapContext context = new CGBitmapContext(
- MIplImage.ImageData,
- Width, Height,
- 8,
- Width * 4,
- cspace,
- CGImageAlphaInfo.PremultipliedLast))
- context.DrawImage(rect, cgImage);
- } else
- {
- using (Image tmp = new Image(cgImage))
- ConvertFrom(tmp);
- }
- }
-
- ///
- /// Convert this Image object to CGImage
- ///
- public CGImage ToCGImage()
- {
- //Don't do this, Xamarin.iOS won't be able to resolve: if (this is Image)
- if (typeof(TColor) == typeof(Rgba) && typeof(TDepth) == typeof(Byte))
- {
- using (CGColorSpace cspace = CGColorSpace.CreateDeviceRGB())
- using (CGBitmapContext context = new CGBitmapContext(
- MIplImage.ImageData,
- Width, Height,
- 8,
- Width * 4,
- cspace,
- CGImageAlphaInfo.PremultipliedLast))
-
- {
- CGImage cgImage = context.ToImage();
- return cgImage;
- }
- } else
- {
- using (Image tmp = Convert())
- {
- return tmp.ToCGImage();
- }
- }
- }
-
- ///
- /// Creating an Image from the UIImage
- ///
- public Image(UIImage uiImage)
- : this( (int) uiImage.Size.Width, (int) uiImage.Size.Height)
- {
- using (CGImage cgImage = uiImage.CGImage)
- {
- ConvertFromCGImage(cgImage);
- }
- }
-
- ///
- /// Convert this Image object to UIImage
- ///
- public UIImage ToUIImage()
- {
- using (CGImage cgImage = ToCGImage())
- {
- return UIImage.FromImage(cgImage);
- }
- }
- }
-}
-
-#endif
\ No newline at end of file
diff --git a/Emgu.CV/PInvoke/iOS/MatiOS.cs b/Emgu.CV/PInvoke/iOS/MatiOS.cs
deleted file mode 100644
index a833fd5d1..000000000
--- a/Emgu.CV/PInvoke/iOS/MatiOS.cs
+++ /dev/null
@@ -1,170 +0,0 @@
-//----------------------------------------------------------------------------
-// Copyright (C) 2004-2019 by EMGU Corporation. All rights reserved.
-//----------------------------------------------------------------------------
-
-#if __IOS__
-using System;
-using System.Drawing;
-using Emgu.CV;
-using Emgu.CV.Structure;
-using CoreGraphics;
-using Emgu.CV.CvEnum;
-using UIKit;
-
-
-namespace Emgu.CV
-{
- public static partial class CvInvoke
- {
- internal static void ConvertCGImageToArray(CGImage cgImage, IOutputArray mat, ImreadModes modes = ImreadModes.AnyColor)
- {
- Size sz = new Size((int)cgImage.Width, (int)cgImage.Height);
- using (Mat m = new Mat(sz, DepthType.Cv8U, 4))
- {
- RectangleF rect = new RectangleF(PointF.Empty, new SizeF(cgImage.Width, cgImage.Height));
- using (CGColorSpace cspace = CGColorSpace.CreateDeviceRGB())
- using (CGBitmapContext context = new CGBitmapContext(
- m.DataPointer,
- sz.Width, sz.Height,
- 8,
- sz.Width * 4,
- cspace,
- CGImageAlphaInfo.PremultipliedLast))
- context.DrawImage(rect, cgImage);
- if (modes == ImreadModes.Grayscale)
- {
- CvInvoke.CvtColor(m, mat, ColorConversion.Rgba2Gray);
- }
- else if (modes == ImreadModes.AnyColor)
- {
- CvInvoke.CvtColor(m, mat, ColorConversion.Rgba2Bgra);
- }
- else if (modes == ImreadModes.ReducedColor2)
- {
- using (Mat tmp = new Mat())
- {
- CvInvoke.PyrDown(m, tmp);
- CvInvoke.CvtColor(tmp, mat, ColorConversion.Rgba2Bgr);
- }
- }
- else if (modes == ImreadModes.ReducedGrayscale2)
- {
- using (Mat tmp = new Mat())
- {
- CvInvoke.PyrDown(m, tmp);
- CvInvoke.CvtColor(tmp, mat, ColorConversion.Rgba2Gray);
- }
- }
- else if (modes == ImreadModes.ReducedColor4 || modes == ImreadModes.ReducedColor8 || modes == ImreadModes.ReducedGrayscale4 || modes == ImreadModes.ReducedGrayscale8 || modes == ImreadModes.LoadGdal)
- {
- throw new NotImplementedException(String.Format("Conversion from PNG using mode {0} is not supported", modes));
- }
- else
- {
- CvInvoke.CvtColor(m, mat, ColorConversion.Rgba2Bgr);
- }
- }
- }
- }
-
- public partial class Mat
- {
- ///
- /// Initializes a new instance of the class from CGImage
- ///
- /// The color conversion mode. By default, it convert the UIImage to BGRA color type to preserve all the image channels.
- /// The CGImage.
- public Mat(CGImage cgImage, ImreadModes mode = ImreadModes.AnyColor)
- : this()
- {
- CvInvoke.ConvertCGImageToArray(cgImage, this, mode);
- }
-
- private static CGImage RgbaByteMatToCGImage(Mat bgraByte)
- {
- using (CGColorSpace cspace = CGColorSpace.CreateDeviceRGB())
- using (CGBitmapContext context = new CGBitmapContext(
- bgraByte.DataPointer,
- bgraByte.Width, bgraByte.Height,
- 8,
- bgraByte.Width * 4,
- cspace,
- CGImageAlphaInfo.PremultipliedLast))
- return context.ToImage();
- }
-
- ///
- /// Converts to CGImage
- ///
- /// The CGImage.
- public CGImage ToCGImage()
- {
- int nchannels = NumberOfChannels;
- DepthType d = Depth;
- if (nchannels == 4 && d == DepthType.Cv8U)
- {
- //bgra
- using (Mat tmp = new Mat())
- {
- CvInvoke.CvtColor(this, tmp, ColorConversion.Bgra2Rgba);
- return RgbaByteMatToCGImage(tmp);
- }
- }
- else if (nchannels == 3 && d == DepthType.Cv8U)
- {
- //bgr
- using (Mat tmp = new Mat())
- {
- CvInvoke.CvtColor(this, tmp, ColorConversion.Bgr2Rgba);
- return RgbaByteMatToCGImage(tmp);
- }
- }
- else if (nchannels == 1 && d == DepthType.Cv8U)
- {
- using (Mat tmp = new Mat())
- {
- CvInvoke.CvtColor(this, tmp, ColorConversion.Gray2Rgba);
- return RgbaByteMatToCGImage(tmp);
- }
- }
- else
- {
- throw new Exception(String.Format("Converting from Mat of {0} channels {1} to CGImage is not supported. Please convert Mat to 3 channel Bgr image of Byte before calling this function.", nchannels, d));
- }
- }
-
-#if __IOS__
- ///
- /// Initializes a new instance of the class from UIImage
- ///
- /// The color conversion mode. By default, it convert the UIImage to BGRA color type to preserve all the image channels.
- /// The UIImage.
- public Mat(UIImage uiImage, ImreadModes mode = ImreadModes.AnyColor)
- : this ()
- {
- using(CGImage cgImage = uiImage.CGImage)
- {
- CvInvoke.ConvertCGImageToArray(cgImage, this, mode);
- }
- }
-
- ///
- /// Converts to UIImage.
- ///
- /// The UIImage.
- public UIImage ToUIImage()
- {
- using (CGImage tmp = ToCGImage())
- {
- return UIImage.FromImage(tmp);
- }
- }
-#else
-
-#endif
-
- }
-
-}
-
-#endif
\ No newline at end of file
diff --git a/Emgu.CV/PInvoke/iOS/UMatiOS.cs b/Emgu.CV/PInvoke/iOS/UMatiOS.cs
deleted file mode 100644
index f80fcbb59..000000000
--- a/Emgu.CV/PInvoke/iOS/UMatiOS.cs
+++ /dev/null
@@ -1,143 +0,0 @@
-//----------------------------------------------------------------------------
-// Copyright (C) 2004-2019 by EMGU Corporation. All rights reserved.
-//----------------------------------------------------------------------------
-
-#if __UNIFIED__
-using System;
-using System.Drawing;
-using Emgu.CV;
-using Emgu.CV.Structure;
-using CoreGraphics;
-using Emgu.CV.CvEnum;
-#if __IOS__
-using UIKit;
-#else
-using AppKit;
-#endif
-
-namespace Emgu.CV
-{
- public partial class UMat
- {
- ///
- /// Initializes a new instance of the class from CGImage
- ///
- /// The color conversion mode. By default, it convert the UIImage to BGRA color type to preserve all the image channels.
- /// The CGImage.
- public UMat(CGImage cgImage, ImreadModes mode = ImreadModes.AnyColor)
- : this()
- {
- CvInvoke.ConvertCGImageToArray(cgImage, this, mode);
- }
-
- private static CGImage RgbaByteMatToCGImage(Mat bgraByte)
- {
- using (CGColorSpace cspace = CGColorSpace.CreateDeviceRGB())
- using (CGBitmapContext context = new CGBitmapContext(
- bgraByte.DataPointer,
- bgraByte.Width, bgraByte.Height,
- 8,
- bgraByte.Width * 4,
- cspace,
- CGImageAlphaInfo.PremultipliedLast))
- return context.ToImage();
- }
-
- ///
- /// Converts to CGImage
- ///
- /// The CGImage.
- public CGImage ToCGImage()
- {
- int nchannels = NumberOfChannels;
- DepthType d = Depth;
- if (nchannels == 4 && d == DepthType.Cv8U)
- {
- //bgra
- using (Mat tmp = new Mat())
- {
- CvInvoke.CvtColor(this, tmp, ColorConversion.Bgra2Rgba);
- return RgbaByteMatToCGImage(tmp);
- }
- }
- else if (nchannels == 3 && d == DepthType.Cv8U)
- {
- //bgr
- using (Mat tmp = new Mat())
- {
- CvInvoke.CvtColor(this, tmp, ColorConversion.Bgr2Rgba);
- return RgbaByteMatToCGImage(tmp);
- }
- }
- else if (nchannels == 1 && d == DepthType.Cv8U)
- {
- using (Mat tmp = new Mat())
- {
- CvInvoke.CvtColor(this, tmp, ColorConversion.Gray2Rgba);
- return RgbaByteMatToCGImage(tmp);
- }
- }
- else
- {
- throw new Exception(String.Format("Converting from Mat of {0} channels {1} to CGImage is not supported. Please convert Mat to 3 channel Bgr image of Byte before calling this function.", nchannels, d));
- }
- }
-
-#if __IOS__
- ///
- /// Initializes a new instance of the class from UIImage
- ///
- /// The color conversion mode. By default, it convert the UIImage to BGRA color type to preserve all the image channels.
- /// The UIImage.
- public UMat(UIImage uiImage, ImreadModes mode = ImreadModes.AnyColor)
- : this ()
- {
- using(CGImage cgImage = uiImage.CGImage)
- {
- CvInvoke.ConvertCGImageToArray(cgImage, this, mode);
- }
- }
-
- ///
- /// Converts to UIImage.
- ///
- /// The UIImage.
- public UIImage ToUIImage()
- {
- using (CGImage tmp = ToCGImage())
- {
- return UIImage.FromImage(tmp);
- }
- }
-#else
- ///
- /// Initializes a new instance of the class from NSImage
- ///
- /// The color conversion mode. By default, it convert the UIImage to BGRA color type to preserve all the image channels.
- /// The NSImage.
- public UMat(NSImage nsImage, ImreadModes mode = ImreadModes.AnyColor)
- : this()
- {
- using (CGImage cgImage = nsImage.CGImage)
- {
- CvInvoke.ConvertCGImageToArray(cgImage, this, mode);
- }
- }
-
- ///
- /// Converts to NSImage.
- ///
- /// The NSImage.
- public NSImage ToNSImage()
- {
- using (CGImage tmp = ToCGImage())
- {
- return new NSImage(tmp, new CGSize(tmp.Width, tmp.Height));
- }
- }
-#endif
-
- }
-}
-
-#endif
\ No newline at end of file
diff --git a/Solution/iOS/Emgu.CV.iOS.Example.sln b/Solution/iOS/Emgu.CV.iOS.Example.sln
index ee7c42817..5ffa366e3 100644
--- a/Solution/iOS/Emgu.CV.iOS.Example.sln
+++ b/Solution/iOS/Emgu.CV.iOS.Example.sln
@@ -13,7 +13,7 @@ Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Emgu.CV.OCR", "..\..\Emgu.C
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Emgu.CV.Contrib", "..\..\Emgu.CV.Contrib\Emgu.CV.Contrib.shproj", "{11E54A7E-778D-466C-A176-71E150976AC1}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emgu.CV.World.IOS", "..\..\Emgu.CV.World\Emgu.CV.World.IOS.csproj", "{0EE2B36C-F7CD-49FA-A270-D7D988CFF6E5}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Emgu.CV.World.IOS", "..\..\Emgu.CV.World\iOS\Emgu.CV.World.IOS.csproj", "{0EE2B36C-F7CD-49FA-A270-D7D988CFF6E5}"
EndProject
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Emgu.CV.XamarinForms", "..\..\Emgu.CV.Example\XamarinForms\Core\Emgu.CV.XamarinForms.shproj", "{F2A5CE86-0B21-40D2-AD3F-BB2D1D716CFE}"
EndProject