Giter Site home page Giter Site logo

emgucv / emgucv Goto Github PK

View Code? Open in Web Editor NEW
2.0K 98.0 568.0 245.7 MB

Emgu CV is a cross platform .Net wrapper to the OpenCV image processing library.

Home Page: https://www.emgu.com/

License: Other

CMake 6.33% C# 55.79% C++ 10.80% C 20.95% Makefile 1.40% M4 0.25% Shell 3.65% Batchfile 0.71% TeX 0.01% Roff 0.02% Visual Basic .NET 0.02% Dockerfile 0.03% Pawn 0.05%
ai computer-vision dotnet emgu emgucv image-classification image-processing image-recognition machine-learning native-bindings

emgucv's Introduction

==================================================================

A cross platform .Net wrapper for the Open CV image-processing library. Allows Open CV functions to be called from .NET compatible languages. The wrapper can be compiled by Visual Studio, Unity and "dotnet" command, it can run on Windows, Mac OS, Linux, iOS and Android.

Please visit our project webpage for more information: http://www.emgu.com/wiki/index.php/Main_Page

Build instructions can be found here: http://www.emgu.com/wiki/index.php/Download_And_Installation#Building_from_Git

emgucv's People

Contributors

agathokakologicalbit avatar aleks-ivanov avatar bernd5 avatar callum-shipton avatar canmingh avatar csbvision avatar emgucv avatar jbruening avatar jeremy7nelson avatar linquize avatar machielvisser avatar muny avatar pt-thowou avatar terman110 avatar wieschie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

emgucv's Issues

Ellipse shifted with 90 degrees (when drawing)

It seems to have a bug in CvInvokeCore.cs when calling the Ellipse method:

      public static void Ellipse(
          IInputOutputArray img,
          RotatedRect box,
          MCvScalar color,
          int thickness = 1,
          CvEnum.LineType lineType = CvEnum.LineType.EightConnected,
          int shift = 0)
      {
         Size axes = new Size();
         axes.Width = (int)Math.Round(box.Size.Height * 0.5);
         axes.Height = (int)Math.Round(box.Size.Width * 0.5);

         Ellipse(img, Point.Round(box.Center), axes, box.Angle, 0, 360, color, thickness, lineType, shift);
      }

axes.Width shoud be defined like this instead : axes.Width = (int)Math.Round(box.Size.Width* 0.5);
axes.Height shoud be defined like this instead : axes.Height = (int)Math.Round(box.Size.Height * 0.5);$

Otherwise the ellipse will be drawn with a 90 degrees offset

Got issue about shape recognition

I'm working on a program which have to recognize rectangles in image,but it doesn't works clearly.
Could you give me some advices or help me about this issue?I've tried some methods of image preprocessing but it doesn't help strongly.

GC.AddMemoryPressure(StructSize.MIplImage) missing in Image.MapDataToImage()

There are two places where an ImageHeader gets allocated using CvInvoke.cvCreateImageHeader(): Image.AllocateData() and Image.MapDataToImage(). The latter gets used if the Image is creatued using unmanaged memory. Both places use _imageDataReleaseMode = ImageDataReleaseMode.ReleaseHeaderOnly, either explicitely or implicitely (default value).

But only Image.AllocateData() calls GC.AddMemoryPressure(StructSize.MIplImage), whereas Image.MapDataToImage() does not!

In both cases Image.DisposeObject() calls GC.RemoveMemoryPressure(StructSize.MIplImage);

So it seems like GC.AddMemoryPressure(StructSize.MIplImage) is missing in Image.MapDataToImage().

Net Standard

Hi guys,

I would like if we could make emguCV netstandard compatible. There is just one bug issue. All platform switches refer to to the real platforms.
With this i mean all the compiler switches like "#if ANDROID" ...

It would be much better if we would define new platform independent compiler switches like:

  • SYSTEM_DRAWING_BITMAP_SUPPORTED

Kind regards,

Bernd

Spelling mistake

There is a spelling mistake with your camera properties:
Emgu.CV.CvEnum.CapProp.Staturation

should be spelt "Saturation"

Please produce NuGet package for latest Emgu CV releases

I realize this has been mentioned before, but I'm not sure it has explicitly been requested. Please produce official NuGet packages for the latest Emgu CV releases (currently Emgu.CV-3.1.0-r16.12). The "old" way of manually including .DLLs is very outdated.

OpenCV: Nonzero offset is not supported in CV_LINK_RUNS yet

In iOS, when trying to use FindContours with LinkRuns I get the exception: OpenCV: Nonzero offset is not supported in CV_LINK_RUNS yet .

The same code works fine in Android. Is this a bug or has this not been implemented yet as the message says.

CvInvoke.FindContours(_edges, _contours, null, RetrType.List,
ChainApproxMethod.LinkRuns);

Running Emgu in server IIS

Hi, I'm having some issues running the Emgu on my server. It runs fine locally, but when I try to use it in the server with an IIS it doesnt work.

Here is the error:

System.TypeInitializationException: The type initializer for 'Emgu.CV.CvInvoke' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'cvextern': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at Emgu.CV.CvInvoke.RedirectError(CvErrorCallback errorHandler, IntPtr userdata, IntPtr prevUserdata)\r\n   at Emgu.CV.CvInvoke..cctor()
   --- End of inner exception stack trace ---
   at Emgu.CV.CvInvoke.cvCreateImageHeader(Size size, IplDepth depth, Int32 channels)
   at Emgu.CV.Image`2.AllocateData(Int32 rows, Int32 cols, Int32 numberOfChannels)
   at Emgu.CV.Image`2.set_Bitmap(Bitmap value)
   at VerifyID.Managers.ImageTreatmentsManager.ExtractDocumentFromImage(Bitmap bitmap)
   at VerifyID.VerifyWorker.ExecuteOCR(BigIdRequest request, BigIdEvent bigIdEvent)

I have the following dlls inside the x86 and x64:
concrt140.dll* liblept172.dll* msvcp140.dll* vcruntime140.dll*
cvextern.dll* libtesseract304.dll* opencv_ffmpeg320.dll*

IIS version: 10.0

Could someone help ?

Build Emgu.CV: CommonAssemblyInfo.cs could not be found

I'm trying to build the Emgu.CV solution inside platform/windows.desktop
But I get this error.

Severity Code Description Project File Line Suppression State
Error CS2001 Source file 'E:\Development\Net\emgucv\Emgu.CV.World..\CommonAssemblyInfo.cs' could not be found. Emgu.CV.World E:\Development\Net\emgucv\Emgu.CV.World\CSC 1 Active

Any idea on how to fix this ?

VideoCapture.Run Non-intercepted exception

VideoCapture.Start calls the method Run through the thread pool. Any exception that occurs in the Run ,that runs in a separate thread, causes the application to crash. Remove from Run exception throw.

  private void Run()
      {
         try
         {
            while (_grabState == GrabState.Running || _grabState == GrabState.Pause)
            {
               if (_grabState == GrabState.Pause)
               {
                  _pauseEvent.WaitOne();
               } else if (IntPtr.Zero.Equals(_ptr) || !Grab())
               {
                  //capture has been released, or
                  //no more frames to grab, this is the end of the stream. 
                  //We should stop.
                  _grabState = GrabState.Stopping;
               }
            }
         }
         catch (Exception e)
         {
     `      // throw new Exception("Capture error", e);
         }
         finally
         {
            _grabState = GrabState.Stopped;
         }
      }

Import Blob Image to Neural Net

hi,

I have been experimenting with the new tensorflow importer and have had the issue when trying to import an image to test my neural net with

`CvInvoke.Resize(image, image, size);

            CvInvoke.CvtColor(image, image, Emgu.CV.CvEnum.ColorConversion.Bgr2Rgb);

            Blob input = new Blob(image);

            net.SetBlob(".input", input);

            net.Forward();`

I have had the issue where it cannot import the input blob image as "OpenCV: input.dims() == 4 && (input.type() == CV_32F || input.type() == CV_64F)"

I have looked it up and this is due to this issue opencv/opencv_contrib#749

Is there an alternate way of achieving this?

Expected member name or ';' after declaration specifiers, Eigen / EmguCV ?

Building EmguCV from source on OSX, I get this error, which I couldn't find in other build processes or bug lists.

In file included from /usr/local/include/eigen3/Eigen/src/Core/ArrayBase.h:93:
/usr/local/include/eigen3/Eigen/src/Core/../plugins/ArrayCwiseUnaryOps.h:184:1: error: 
      expected member name or ';' after declaration specifiers
sign() const
^
/Users/mariannedang/emgucv/opencv_contrib/modules/tracking/include/opencv2/tracking/onlineMIL.hpp:57:23: note: 
      expanded from macro 'sign'
#define  sign(s)  ((s > 0 ) ? 1 : ((s<0) ? -1 : 0))

...

In file included from /usr/local/include/eigen3/Eigen/src/Core/ArrayBase.h:93:
/usr/local/include/eigen3/Eigen/src/Core/../plugins/ArrayCwiseUnaryOps.h:184:1: error: 
      expected ')'
/Users/mariannedang/emgucv/opencv_contrib/modules/tracking/include/opencv2/tracking/onlineMIL.hpp:57:23: note: 
      expanded from macro 'sign'
#define  sign(s)  ((s > 0 ) ? 1 : ((s<0) ? -1 : 0))
                      ^
/usr/local/include/eigen3/Eigen/src/Core/../plugins/ArrayCwiseUnaryOps.h:184:1: note: 
      to match this '('
/Users/mariannedang/emgucv/opencv_contrib/modules/tracking/include/opencv2/tracking/onlineMIL.hpp:57:20: note: 
      expanded from macro 'sign'
#define  sign(s)  ((s > 0 ) ? 1 : ((s<0) ? -1 : 0))
                   ^

I'm running OSX 10.12.5, and just checked out the emgucv EMGUCV_3_1 branch. It's possible it's a versioning issue with Eigen, but I don't know how to check that, and other issues haven't been reported online yet.

Any help would be appreciated!

Add nuget files to the repository

It would be nice if the nuget related files could be added to the repository, so that they can be improved by the community when necessary.

I would like to contribute to them, but because they don't seem to be included in the repository yet, I have to keep my world order changing source code improvements to myself.

Invert Memory Leak

EmguCV version: 3.1.0.2504

Details:
There's a noticeable memory leak with the "Image<Bgr, byte>.Not" method. I've tested this with images of varying sizes; however, it's exacerbated when using a larger image and larger scale. The example below is running against an image at resolution 1920x1080.

I am monitoring the Private Byte growth using Process Explorer's Performance Graph.
https://technet.microsoft.com/en-us/sysinternals/processexplorer.aspx

Setup:

        Bitmap newImg = new Bitmap(@"C:\Users\wesley.murphree\Pictures\test.png");
        int i = 0;
        Console.WriteLine("PRESS ENTER...");
        Console.ReadLine();
        do
        {
            Console.WriteLine("Iteration: " + i.ToString());
            Bitmap output = OpenCV.Invert(newImg);
            output.Dispose();
            Console.Write("Processed.  Sleeping 5 seconds....");
            System.Threading.Thread.Sleep(5000);
        }
        while (++i < 5);
        newImg.Dispose();

        Console.WriteLine("\nFinished.  Press enter to close");
        Console.ReadLine();

Function:

    public static Bitmap Invert(Bitmap source)
    {
        Emgu.CV.Image<Emgu.CV.Structure.Bgr, byte> imgBgrSource = new Emgu.CV.Image<Emgu.CV.Structure.Bgr, byte>(source);
        Emgu.CV.Image<Emgu.CV.Structure.Bgr, byte> inverted = imgBgrSource.Not();
        imgBgrSource.Dispose();

        Bitmap bmpImg = inverted.ToBitmap();
        inverted.Dispose();

        return bmpImg;
    }

Emgucv doesn't build with Mono 5.0.1.1

Microsoft (R) Visual C# Compiler version 2.0.0.61404
Copyright (C) Microsoft Corporation. All rights reserved.

/media/ubuntu/b8494351-d45f-45e7-9e1b-1e953eb450d9/emgucv/Emgu.CV.Cuda/Legacy/CudaBackgroundSubtractorFGD.cs(76,57): warning CS1573: Parameter 'forgroundMask' has no matching param tag in the XML comment for 'CudaBackgroundSubtractorFGD.Apply(IInputArray, IOutputArray, double)' (but other parameters do)
/media/ubuntu/b8494351-d45f-45e7-9e1b-1e953eb450d9/emgucv/Emgu.CV.Cuda/Legacy/CudaBackgroundSubtractorGMG.cs(34,57): warning CS1573: Parameter 'forgroundMask' has no matching param tag in the XML comment for 'CudaBackgroundSubtractorGMG.Apply(IInputArray, IOutputArray, double, Stream)' (but other parameters do)
error CS7027: Error signing output with public key from file '/media/ubuntu/b8494351-d45f-45e7-9e1b-1e953eb450d9/emgucv/Emgu.CV.World/../Emgu.CV.snk' -- mscoree.dll
Emgu.CV.World/CMakeFiles/Emgu.CV.World.dir/build.make:57: recipe for target 'Emgu.CV.World' failed
make[2]: *** [Emgu.CV.World] Error 1
CMakeFiles/Makefile2:9607: recipe for target 'Emgu.CV.World/CMakeFiles/Emgu.CV.World.dir/all' failed
make[1]: *** [Emgu.CV.World/CMakeFiles/Emgu.CV.World.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2

how can I modify transitionMatrix ? readonly

Emgu.CV.World, Version=3.1.0.2504, Culture=neutral, PublicKeyToken=7281126722ab4438

namespace Emgu.CV
{
//
// 摘要:
// The class implements a standard Kalman filter. However, you can modify transitionMatrix,
// controlMatrix, and measurementMatrix to get an extended Kalman filter functionality.
public class KalmanFilter : UnmanagedObject
{
//
// 摘要:
// Initializes a new instance of the Emgu.CV.KalmanFilter class.
//
// 参数:
// dynamParams:
// Dimensionality of the state.
//
// measureParams:
// Dimensionality of the measurement.
//
// controlParams:
// Dimensionality of the control vector.
//
// type:
// Type of the created matrices that should be Cv32F or Cv64F
public KalmanFilter(int dynamParams, int measureParams, int controlParams, DepthType type = DepthType.Cv32F);

    //
    // 摘要:
    //     Control matrix (B) (not used if there is no control)
    public Mat ControlMatrix { get; }
    //
    // 摘要:
    //     posteriori error estimate covariance matrix (P(k)): P(k)=(I-K(k)*H)*P'(k)
    public Mat ErrorCovPost { get; }
    //
    // 摘要:
    //     priori error estimate covariance matrix (P'(k)): P'(k)=A*P(k-1)*At + Q)
    public Mat ErrorCovPre { get; }
    //
    // 摘要:
    //     Kalman gain matrix (K(k)): K(k)=P'(k)*Ht*inv(H*P'(k)*Ht+R)
    public Mat Gain { get; }
    //
    // 摘要:
    //     Measurement matrix (H)
    public Mat MeasurementMatrix { get; }
    //
    // 摘要:
    //     Measurement noise covariance matrix (R)
    public Mat MeasurementNoiseCov { get; }
    //
    // 摘要:
    //     Process noise covariance matrix (Q)
    public Mat ProcessNoiseCov { get; }
    //
    // 摘要:
    //     Corrected state (x(k)): x(k)=x'(k)+K(k)*(z(k)-H*x'(k))
    public Mat StatePost { get; }
    //
    // 摘要:
    //     Predicted state (x'(k)): x(k)=A*x(k-1)+B*u(k)
    public Mat StatePre { get; }
    //
    // 摘要:
    //     State transition matrix (A)
    public Mat TransitionMatrix { get; }

    //
    // 摘要:
    //     Updates the predicted state from the measurement.
    //
    // 参数:
    //   measurement:
    //     The measured system parameters
    public Mat Correct(Mat measurement);
    //
    // 摘要:
    //     Perform the predict operation using the option control input
    //
    // 参数:
    //   control:
    //     The control.
    //
    // 返回结果:
    //     The predicted state.
    public Mat Predict(Mat control = null);
    //
    // 摘要:
    //     Release the unmanaged resources
    protected override void DisposeObject();
}

}

CvInvoke.cvResetImageROI does not work correctly

EmguCV version: 3.2.0, TargetPlatform x64

When I set a ROI on an Image and reset it later via CvInvoke.cvResetImageROI(IntPtr image) the ROI is not properly set the full image size. You will get a CVException : OpenCV: mask.empty() || (mask.type() == CV_8U && size == mask.size) when performing operations on that image. When one uses img.ROI = Rectangle.Empty instead, same code woks. I Added an small example below.

static void Main(string[] args)
{
      var img = new Image<Gray, float>(100, 100);
      var mask = new Image<Gray,byte>(100, 100);
      mask.ROI = new Rectangle(0,0,50,50);

      CvInvoke.cvResetImageROI(mask.Ptr);  //SetValue throws exception
      //mask.ROI = Rectangle.Empty;        //SetValue works

      img.SetValue(new Gray(255), mask);
}

Unable to compile emgucv on osx 10.12.3

Errror-message:

Linking CXX shared library ../bin/libcvextern.dylib
ld: library not found for -lgphoto2
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [bin/libcvextern.dylib] Error 1
make[1]: *** [Emgu.CV.Extern/CMakeFiles/cvextern.dir/all] Error 2
make: *** [all] Error 2

Build issue on Raspbian

I was trying to build building EmguCV on Raspbian using instructions from here. Looks like vtk is compiled normally, (during ./cmake_configure), but build fails on opencv with error:

CMake Error at opencv/CMakeLists.txt:11 (message):


  FATAL: In-source builds are not allowed.

         You should create separate directory for build files.



-- Configuring incomplete, errors occurred!
See also "/home/pi/emgucv/CMakeFiles/CMakeOutput.log".
See also "/home/pi/emgucv/CMakeFiles/CMakeError.log".

Looks like, this need patches in CMake files, but I don't know how to make this work...

Aruco Detector crashes

Hello
I am trying to use the aruco detector from opencv contrib with images from a kinect, but it crashes all the time.
Even the example crashes (using a standard logitech webcam) and i tested both the precompiled executable and running from source

Has anyone succeded detecting aruco markers, if yes how ?
Thanks a lot !

Dependencies are not copied to output path of another referencing project with msbuild and nuget

If you build a library project in Visual Studio, include the emgucv package using nuget and compile everything, you will get the x86 and x64 sub directories inside your ouput directory as expected.

Unfortunately, if you create another project that references this library project and compile it, the x86 and x64 sub directories will not be copied to the output directory of the newly created project and thus causing it to fail when calling any library project function that uses emgucv.

To solve this problem, you have to change a single file which is distributed together with the nuget package.

The EmguCV.targets file looks like this:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup>
    <OpenCVBinX64 Include="$(MSBuildThisFileDirectory)\native\x64\*.dll" />
    <OpenCVBinX86 Include="$(MSBuildThisFileDirectory)\native\x86\*.dll" />
  </ItemGroup>
  <Target Name="AfterBuild">
    <Copy SourceFiles="@(OpenCVBinX64)" DestinationFolder="$(OutputPath)\x64" ContinueOnError="true" SkipUnchangedFiles="true" Condition="$(CopyOpenCVBins)"/>
    <Copy SourceFiles="@(OpenCVBinX86)" DestinationFolder="$(OutputPath)\x86" ContinueOnError="true" SkipUnchangedFiles="true" Condition="$(CopyOpenCVBins)"/>
  </Target>
</Project>

If you replace it with the following code, it will work in both scenarios:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup Condition="'$(CopyOpenCVBins)'"> 
    <Content Include="$(MSBuildThisFileDirectory)\native\x64\*.dll">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Link>x64\%(Filename)%(Extension)</Link>
    </Content>
    <Content Include="$(MSBuildThisFileDirectory)\native\x86\*.dll">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Link>x86\%(Filename)%(Extension)</Link>
    </Content>
  </ItemGroup>
</Project>

FindEssentialMat() wrong return type?

Hi, When I try to find the essential matrix I cannot get the result from the method.
Emgu source emgucv/Emgu.CV/PInvoke/CvInvokeCalib3d.cs:
public static void FindEssentialMat(IInputArray points1, IInputArray points2, IInputArray cameraMatrix, CvEnum.FmType method = CvEnum.FmType.Ransac, double prob = 0.999, double threshold = 1.0, IOutputArray mask = null);

Opencv source:
cv::Mat cv::findEssentialMat( InputArray _points1, InputArray _points2, InputArray _cameraMatrix, int method, double prob, double threshold, OutputArray _mask)
Shouldn't the Emgu method return a Mat or am I doing it wrong?

Reading 16 bit tif file

Hi,

Reading 16 bit TIF file has a problem. After reading TIF image and trying to access the data, it turned 8 bit data.
Image <Gray, UInt16> tiff_image = new Image <Gray, UInt16> ("Filename.tif");

PNG worked ok.

I used 3.1.0.2504

Debugging not possible in VS2015

I migrated a VS2015 project which uses emgucv from version 2.4.2 to 3.2.0. Since I did so I am not able to catch exceptions anymore. Every time an EmguCV Exception is thrown, it pops up for about half a second, but then the whole debugging process stops working and the exception window vanishes. This behavior makes it impossible to work out the issues due to the migration from 2.4.2 to 3.2.0.

My Project is a x64 WPF application, the screen shows which opencv dlls I am using and how I have integrated them into the project. All dlls are all set to content and copy always.

image

When reverting all changes and going back to version 2.4.2 debugging works perfectly.

Investigation on StackOverflow has shown that more people have that problem, but a solution does not exist right now.

Missing cvextern.dll

Hi,
I've just downloaded the repo to test it. Try to compile RealtimeCamera (Universal Windows) and I get the error:
This package do not contain necessary binary for Windows 10 UWP (32bit). Emgu CV for Windows Commercial License is required. Missing cvextern.dll ' Emgu.CV\Emgu.CV.projitems
According to your licensing page, how can I run that sample under the Open Source Licensing?

thank you
-g

new VideoCapture(string) crashes app

When creating new VideoCapture class from non-existent stream, application crashes silently with no possibility to catch exception:
var cap = new VideoCapture(offlineStreamString);

?

Hello! It is impossible to compile! Whether could lay out you on sourceforge.net all of library (x86, x64 Windows).

Bug in CVArray - IXmlSerializable ReadXml

I have a class similar to the following:

public class CalibrationInfo { public Matrix<double> intrinsicMatrix; public Matrix<double> _istortionCoeffs; }

When I tried to serialize the class using XmlSerializer no problems but when I deserialized the object, the data in the matrices after the first property were all zeros It seems that when you implement ReadXml() you have to move pass the current node/element.

I added code like the following to fix the issue:
do { reader.Read(); } while (reader.NodeType != XmlNodeType.Element && reader.NodeType != XmlNodeType.None);
I did not try other scenarios so not sure if this handles all cases.

Exception in cveMatCreateData when creating many Mat objects

The program below throws an exception in Emgu.CV.MatInvoke.cveMatCreateData(IntPtr mat, Int32 row, Int32 cols, Int32 type) after a varying number of iterations each time it is run. I'm using Visual Studio 2010 and the .NET Framework version 4.6 on Windows 7 64-bit.

Is this a bug in EmguCV?

using Emgu.CV;
using Emgu.CV.CvEnum;

namespace EmguCV_crasher_2
{
    class Program
    {
        static void f(int ii)
        {
            for (var i = 0; i < 100; i++)
            {
                // Unhandled exception occurs in Mat().
                // Iteration causing exception varies.  Can be ii = 277, i = 43.
                // Stack trace: 
                //  at Emgu.CV.CvInvoke.CvErrorHandler(Int32 status, IntPtr funcName, IntPtr errMsg, IntPtr fileName, Int32 line, IntPtr userData)
                //  at Emgu.CV.MatInvoke.cveMatCreateData(IntPtr mat, Int32 row, Int32 cols, Int32 type)
                //  at Emgu.CV.Mat.Create(Int32 rows, Int32 cols, DepthType type, Int32 channels)
                //  at Emgu.CV.Mat..ctor(Int32 rows, Int32 cols, DepthType type, Int32 channels)
                //  at EmguCV_crasher_2.Program.f(Int32 ii) in C:\Visual Studio 2010\Projects\EmguCV_crasher_2\EmguCV_crasher_2\Program.cs:line 17
                //  at [etc.]
                var m = new Mat(128, 128, DepthType.Cv32F, 1);
            }
        }
        static void Main(string[] args)
        {
            for (var i = 0; i < 1000; i++)
            {
                f(i);
            }
        }
    }
}

CvInvoke.UseOpenCL resets back to true

I have the 3.1 R16 release on Android

When I have device with UseOpenCL set to true by default, but I change it to false, then it returns "after some time" back to true.

It's not really deterministic. In my case I have reproduced this on Android devices Samsung S6 and Lenovo VIBE P1 with the following steps:

  1. set UseOpenCL to false in constructor
  2. call a function in click event with some CvInvoke operations -- UseOpenCL is false
  3. then on next click in the same function is UseOpenCL true without setting it to true

I am not really sure in which moment it resets back to true. If I called the same function with CvInvokes on one click twice, then OpenCL was false in both cases but on next click was true again :(

I am trying mainly to disable OpenCL because it doesn't work correctly on Samsung S6 (images are black, or broken in different ways. But that's imho another bug. I tried my app on around 6 different devices but nowhere else was this problem.)

The current workaround for me is setting UseOpenCL to false in every function where I need it

Watershed function

Hello,

This is my first time using EmguCV. If I make any mistakes, please forgive me...
I would like to apply Watershed function but I've got a blank (white) output. I copied this example code from the internet. I don't know what else I could do, please help me.

Image<Bgr, Byte> image = new Image<Bgr, byte>("input.jpg");
Image<Gray, Int32> marker = new Image<Gray, Int32>(image.Width, image.Height);
Rectangle rect = image.ROI;
marker.SetZero();
marker.Draw(new CircleF(new PointF(rect.Left + rect.Width / 2.0f, rect.Top + rect.Height / 2.0f), (float)(Math.Min(image.Width, image.Height) / 4.0f)), new Gray(255), 0);
CvInvoke.Watershed(image, marker);

FPS bug in VideoWriter Constructor

The VideoWriter constructor incorrectly uses an int for fps. The OpenCV equivalent correctly uses a double.

This means that 30 fps videos, commonly actually 29.97 fps or so it would appear, are written at 29 fps due to truncation.

This means that any extracted audio from the source video cannot be re-inserted without sync issues post OpenCV processing. It also means the output video is at a different frame rate from the unprocessed source.

Resize Memory Leak

EmguCV version: 3.1.0.2504

Similar issue:
http://answers.opencv.org/question/93006/resize-memory-leak-minor/

Details:
There's a noticeable memory leak with the "Image<TColor, TDepth>.Resize" method. The leak isn't as bad when using the "Emgu.CV.CvInvoke.Resize" method but it's still present. I've tested this with images of varying sizes; however, it's exacerbated when using a larger image and larger scale. The example below is running against an image at resolution 1920x1080.

I am monitoring the Private Byte growth using Process Explorer's Performance Graph.
https://technet.microsoft.com/en-us/sysinternals/processexplorer.aspx

Setup:

    Bitmap imageToProcess = new Bitmap(@"C:\Users\wesley.murphree\Pictures\test.png");
    OpenCV<ConfigSetting>.Resize(imageToProcess, 400, 400, OpenCV.Scaling.Grow);
    imageToProcess.Dispose();

Function:

    public enum Scaling
    {
        Shrink,
        Grow
    }
    /// <summary>
    /// Shrinks or grows an image based on percent width and height
    /// </summary>
    /// <param name="source">Image to resize</param>
    /// <param name="percentWidth">Percent as whole number</param>
    /// <param name="percentHeight">Percent as whole number</param>
    /// <returns></returns>
    public static Bitmap Resize(Bitmap source, int percentWidth, int percentHeight, Scaling scale)
    {
        try
        {
            Emgu.CV.Image<Emgu.CV.Structure.Bgr, byte> imgBgrSource = new Emgu.CV.Image<Emgu.CV.Structure.Bgr, byte>(source);

            #region Calcuate Width and Height based on percent
            int width = 0;
            int height = 0;
            if (scale == Scaling.Grow)
            {
                if (percentWidth < 1 || percentHeight < 1)
                    throw new Exception("Resize: Value must be greater than 0");

                int widthAdd = 0;
                if (percentWidth < 100)
                    widthAdd = 1;
                int heightAdd = 0;
                if (percentHeight < 100)
                    heightAdd = 1;
                width = Convert.ToInt32(imgBgrSource.Width * (widthAdd + (percentWidth * 0.01)));
                height = Convert.ToInt32(imgBgrSource.Height * (heightAdd + (percentHeight * 0.01)));
            }
            else
            {
                if ((percentWidth >= 100 || percentHeight >= 100)
                    || (percentWidth < 1 || percentHeight < 1))
                    throw new Exception("Resize: Value must be between 1 and 100");
                percentWidth = 100 - percentWidth;
                percentHeight = 100 - percentHeight;
                width = Convert.ToInt32(imgBgrSource.Width * (percentWidth * 0.01));
                height = Convert.ToInt32(imgBgrSource.Height * (percentHeight * 0.01));
            }
            #endregion

            /*
            //UNCOMMENT THIS SECTION TO TEST USING CvInvoke.Resize
            Emgu.CV.Image<Emgu.CV.Structure.Bgr, byte> output = imgBgrSource.CopyBlank();
            Emgu.CV.CvInvoke.Resize(imgBgrSource, output, new Size(width, height), 0, 0, interpolation: Emgu.CV.CvEnum.Inter.Linear);
            output.Dispose();
            */

            Emgu.CV.Image<Emgu.CV.Structure.Bgr, byte> largeImg = imgBgrSource.Resize(width, height, Emgu.CV.CvEnum.Inter.Linear);

            imgBgrSource.Dispose();
            largeImg.Dispose();
            return null;// return imgBgrSource.ToBitmap();
        }
        catch (Exception ex)
        {
            throw;
        }
    }

VideoCapture.Retrieve method throw AccessViolationException

I creat a program to capture RTSP video stream. After image recieption, some image process has been done(face recognize with thrid party library), during the whole time, retrieve method would throw the AccessviolationException occasionally, sometimes it holds in a hour, but sometimes it holds hours. Here is my code:

if (_capture != null && _capture.Ptr != IntPtr.Zero)
{
    try
    {
        if (_capture.Retrieve(_receivedImage))
        {
            _emptyFrameCount = 0;

            if (_shouldShot)
            {
                WriteFeature(_receivedImage.Bitmap);
                _shouldShot = false;
            }

            CvInvoke.Resize(_receivedImage, _resizedImage,
                new Size(_receivedImage.Width / 2, _receivedImage.Height / 2));

            Verify(_resizedImage.Bitmap);

            //videoImage.Image?.Dispose();
            videoImage.Image = _resizedImage.Bitmap;
        }
        else
        {
            ProcessEmpty();
        }
    }
    catch (Exception error)
    {
        File.AppendAllText("log.txt", $"{error.Message}{Environment.NewLine}");
    }
}

This code snippet are running in a thread, and will be called every 30ms.

Superres.FrameSource not faifthfully ported - should be interface

OpenCV's Superres.FrameSource is an interface, which has two subclasses off it to implement camera sources and video file sources natively. Emgu seems to pull these classes into the main FrameSource class. This is a problematic for people like me who need to make their own subclass off FrameSource and have it be accepted by the Superres method.

By the way, as a workaround, what codecs does the precompiled version natively support? I tried MPEG-4 and H.264, but it didn't seem too happy with either.

Densehistogram class Caculate method no longer support input as IImage[]

Hello.
I convert emgu in my project from emgu 2.4.10 to emgu 3.2.0.
I found that Calculate(IImage[] imgs, bool accumulate, Image<Gray, Byte> mask) is annotated in Emgu ver 3.2.0.

What is the reason to do that?? and Is there any other way to execute Calculate method without Depth Information?

FastDetector.DetectAndCompute excepts but DetectRaw + Compute works.

Hello,

I'm trying to make a FAST detector, using this code from the site:
http://www.emgu.com/wiki/index.php/FAST_feature_detector_in_CSharp
but updating the code to work with the 3.1 NuGet package.

This will crash in Emgu.CV.World.dll with no useful information -- If I comment out DetectAndCompute, and uncomment DetectRaw and Compute, it works a little longer( routine still crashes, but at a different point ):

public static Mat DrawFAST(Mat modelImage, Mat observedImage)
Mat homography = new Mat();

        FastDetector fastCPU = new FastDetector(10, true);
        VectorOfKeyPoint modelKeyPoints = new VectorOfKeyPoint();
        VectorOfKeyPoint observedKeyPoints = new VectorOfKeyPoint();

        BriefDescriptorExtractor descriptor = new BriefDescriptorExtractor();
        VectorOfVectorOfDMatch matches = new VectorOfVectorOfDMatch();

        Mat mask = null;
        int k = 2;
        double uniquenessThreshold = 0.8;

        //extract features from the object image
        //fastCPU.DetectRaw(modelImage, modelKeyPoints);  // This would work
        Mat modelDescriptors = new Mat();
        //descriptor.Compute(modelImage, modelKeyPoints, modelDescriptors); // This would work

        fastCPU.DetectAndCompute(modelImage, null, modelKeyPoints, modelDescriptors, false); // This will crash, but I don't see why.

Hangs on creating Capture or grabbing from offline IP-camera

Very simple code to reproduce subject. It completely stucks. I can't even kill thread or cancel task whenever it hangs.

Using EmguCV 3.1.0.1 NuGet package

using Emgu.CV;
using System;

namespace OpenCVTest
{
    class Program
    {
        static void Main(string[] args)
        {
            // if camera offline from start, program stucks here.
            var capture = new Capture(@"rtsp://192.168.123.123/");

            // if camera becomes and stays offline mone than 20-30 seconds, program stucks here
            while (capture.Grab())
            {
                Console.Write("grab.");
            }
        }
    }
}

Color conversion from Bgra to any Yuv fail in CvInvoke

I have a Mat that is from an Image<Bgra, byte>. If I try to do a CvInvoke.CvtColor(originalMat, convertedMat, ColorConversion.Bgra2YuvI420) the code fails in the CvInvoke call.

EmguCV version emgucv-windesktop_x64-cuda-tbb-ipp-icc 3.1.0.2504
Program compiled for x64

Will 3.1.0-r16.12 be released on NuGet?

The latest release on NuGet is 3.1.0.1. All of the documentation appears to be for 3.1.0-r16.12.

Are there plans to release 3.1.0-r16.12 on NuGet? If so, when?


I'm not familiar with your versioning scheme yet, but it seems like 3.1.0-r16.12 is a pre-release. I'm primarily a Python developer so I'm used to pre-release versions being available on PyPI. I don't know if NuGet allows pre-release or not, so this request might be invalid.

Access to null in 'CudaGoodFeaturesToTrackDetector'

File: Emgu.CV.Cuda\Imgproc\CudaGoodFeaturesToTrackDetector.cs
Version: emgucv 3.2.0.2682
Line: 36
Position: 38 to 96
Pull request: #42

Program might crash if mask is null.
Please consider reviewing the following code:

cudagoodfeaturestotrackdetector_bug_marked

Ternary operator ? will execute left part if expression is truthly, else - right part will be executed.
When mask == null this part of code tries to get it's property mask.GetInputArray().

Maybe it should be written as mask != null or 2 expressions need to be swapped.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.