Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Missing binding to cvtColorTwoPlane #891

Open
softlion opened this issue Nov 15, 2023 · 4 comments
Open

[BUG] Missing binding to cvtColorTwoPlane #891

softlion opened this issue Nov 15, 2023 · 4 comments
Assignees

Comments

@softlion
Copy link

Describe the bug
For some reason this method cvtColorTwoPlane, available since opencv v3 is not bound:

** OS / Platform **
all

** .Net version **
Xamarin

** Emgu CV package used**
4.8.1

@softlion
Copy link
Author

It would look something like this. It is missing the bindings in the cveCvtXXXX

        public static void CvtColorTwoPlane(IInputArray src1, IInputArray src2, IOutputArray dest, System.Type srcColor, System.Type destColor)
        {
            try
            {
                CvtColorTwoPlane(src1, src2, dest, CvToolbox.GetColorCvtCode(srcColor, destColor));
            }
            catch (Exception ex)
            {
                throw new NotSupportedException($"There is an error converting {(object)srcColor.ToString()} to {(object)destColor.ToString()}: {(object)ex.Message}", ex);
            }
        }

        /// <summary>
        /// Converts an image from one color space to another where the source image is stored in two planes.
        /// This function only supports YUV420 to RGB conversion as of now.
        /// </summary>
        /// <param name="src1">The source 8-bit (8u) image</param>
        /// <param name="src2">image containing interleaved U/V plane</param>
        /// <param name="dst">The destination image of the same data type as src1. The number of channels will be different</param>
        /// <param name="code">Specifies the type of conversion. See remarks for supported conversion codes</param>
        /// <remarks>
        /// Doc: https://docs.opencv.org/4.8.0/d8/d01/group__imgproc__color__conversions.html#ga8e873314e72a1a6c0252375538fbf753
        ///
        /// Supported conversion codes:
        /// COLOR_YUV2BGR_NV12
        /// COLOR_YUV2RGB_NV12
        /// COLOR_YUV2BGRA_NV12
        /// COLOR_YUV2RGBA_NV12
        /// COLOR_YUV2BGR_NV21
        /// COLOR_YUV2RGB_NV21
        /// COLOR_YUV2BGRA_NV21
        /// COLOR_YUV2RGBA_NV21
        /// </remarks>
        public static void CvtColorTwoPlane(IInputArray src1, IInputArray src2, IOutputArray dst, ColorConversion code)
        {
            using var inputArray1 = src1.GetInputArray();
            using var inputArray2 = src2.GetInputArray();
            using var outputArray = dst.GetOutputArray();
            cveCvtColorTwoPlane((IntPtr) (UnmanagedObject) inputArray1, (IntPtr) (UnmanagedObject) inputArray2, (IntPtr) (UnmanagedObject) outputArray, code);
        }

        [DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
        private static extern void cveCvtColorTwoPlane(IntPtr src1, IntPtr src2, IntPtr dst, ColorConversion code);

@emgucv
Copy link
Owner

emgucv commented Nov 16, 2023

Fixed in this commit: e7860dd

Will be included in the next release.

@softlion
Copy link
Author

Fixed in this commit: e7860dd

Will be included in the next release.

ty!
Quick question, why don't you use the new using syntax instead of the old syntax with parenthesis ?

@emgucv
Copy link
Owner

emgucv commented Nov 18, 2023

We do not use the new "using" syntax without curly braces, such that our code can be compiled by compilers older than c# 8.0 (e.g. Unity 3D).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants