logo
down
shadow

EmguCV: How to create a covariation matrix from image?


EmguCV: How to create a covariation matrix from image?

By : robot
Date : November 16 2020, 06:23 AM
To fix the issue you can do The mistake was the 2nd parameter of cvCalcCovarMatrix(imageptr,count, cov, avg, COVAR_METHOD.CV_COVAR_NORMAL);
Correct is:
code :


Share : facebook icon twitter icon
EmguCV - Create image from unmanaged data

EmguCV - Create image from unmanaged data


By : user3052147
Date : March 29 2020, 07:55 AM
Does that help You most likely passed something wrong as the pointer. A wrong stride would just result in the image contents appearing distorted. 640 would be the correct value in your case (just use width again) as the stride always represents the length of one image line in memory (in your case 640 bytes). I can just guess but don't try to use the matrix's _ptr pointer. This might sound logical but that one will point to the whole matrix object and not just the data (you want). Without checking right now, I'm rather sure you're able to use the matrix's copyTo() to copy the contents to an image (if that's sufficient for your use case).
How to set values for multichannel matrix in Emgucv

How to set values for multichannel matrix in Emgucv


By : Alex
Date : March 29 2020, 07:55 AM
Hope that helps If you look at matrixa.Data, this will be a float[,] with the first dimension corresponding to rows and the second being the columns and channels merged into one dimension. If the number of channels is N, the current channel is n and the current column is m, the index j of the second dimension is
code :
j = m*N + n
for (int i = 0; i < usablePoints.Count; ++i)
{
  matrixa.Data[i, 0] = usablePoints[i].X;
  matrixa.Data[i, 1] = usablePoints[i].Y;
}
j = m*N + n = 3*3 + 2 = 11
=>
matrixa.Data[1, 11] = 1;
copy multiple 1D matrix into one large 1D matrix in Emgucv or Opencv

copy multiple 1D matrix into one large 1D matrix in Emgucv or Opencv


By : Konstantin Zhukov
Date : March 29 2020, 07:55 AM
this one helps. I was trying to create a large Matrix contain rows images of tablets to use PCA function in Emgucv. I was success in reshaping the tablet image (let say MxN) to a matrix ( 1 row,MxN column).Now I want to copy it to row i of the large Matrix ( k row, MxN column).Here is my code: , This is pretty easy. I'm sorry I only have C++ code for you though.
code :
cv::Mat dest; // size NxM (rowsxcols)
cv::Mat src; // size N
cv::Mat row(dest.row(i));
src.copyTo(row);
What is the fundamental difference between Matrix<TDepth> and Mat in EmguCV?

What is the fundamental difference between Matrix<TDepth> and Mat in EmguCV?


By : user2022954
Date : March 29 2020, 07:55 AM
I hope this helps . Based on the information from the Emgu Wiki the fundamental difference between the two types is whether the underlying data array is managed or not.
Mat is a wrapper around the C++ cv::Mat class. Generally this class acts as a smart pointer which manages the memory allocated for the data array it owns (although it's able to just observe as well -- a good example of this capability is the ability to return a Mat header for a Matrix instance in C#). This means that OpenCV is able to (re)allocate the memory as necesssary. The trade-off is that in such cases it's more difficult to access the underlying data effectively in C#.
How can I convert Image to Matrix and then Matrix to Bitmap in EmguCV?

How can I convert Image to Matrix and then Matrix to Bitmap in EmguCV?


By : Art Gonzalez
Date : March 29 2020, 07:55 AM
will be helpful for those in need Converting Image to Matrix
The important thing to notice here is that both Image and Matrix inherit from CvArray. That means it is possible to use the (inherited) method CopyTo to copy the data from an Image instance to a Matrix instance of identical depth and dimensions.
code :
Image<Bgr, byte> color = ... ; // Initialized in some manner

Matrix<byte> matrix = new Matrix<byte>(color.Rows, color.Cols, color.NumberOfChannels);

color.CopyTo(matrix);
Bitmap b = matrix.Mat.Bitmap;
matrix.CopyTo(color);
Bitmap b = color.Bitmap;
Bitmap b = color.ToBitmap();
using System;
using System.Drawing;
using Emgu.CV;
using Emgu.CV.Structure;
// ============================================================================
namespace CS1 {
// ============================================================================
class Test
{
    static void Main()
    {
        Image<Bgr, byte> color = new Image<Bgr, byte>(2, 2);
        for (int r = 0; r < color.Rows; r++) {
            for (int c = 0; c < color.Cols; c++) {
                int n = (c + r * color.Cols) * 3;
                color[r, c] = new Bgr(n, n+1, n+2);
            }
        }

        Matrix<byte> matrix = new Matrix<byte>(color.Rows, color.Cols, color.NumberOfChannels);

        color.CopyTo(matrix);

        Bitmap b = matrix.Mat.Bitmap;

        matrix.CopyTo(color);

        b = color.Bitmap;

        b = color.ToBitmap();
    }
}
// ============================================================================
} // namespace CS1
// ============================================================================
cmake_minimum_required(VERSION 3.11)
project(CS1 VERSION 0.1.0 LANGUAGES CSharp)

add_executable(cs1
    src/test.cs
)

set_property(TARGET cs1
    PROPERTY VS_DOTNET_TARGET_FRAMEWORK_VERSION "v4.6.1"
)

set_property(TARGET cs1 
    PROPERTY VS_DOTNET_REFERENCES
    "System"
    "System.Drawing"
)

set_target_properties(cs1 PROPERTIES 
    VS_DOTNET_REFERENCE_emgu_cv_world "deps/Emgu.CV.World.dll"
)
Related Posts Related Posts :
  • Why does C# also not allow empty conditions in while loops?
  • Unable to get a block of code into my regex match groups
  • What is difference between dbcontext.Add and dbcontext.AddObject
  • How do I update the file version number of C# DLL without recompiling?
  • Value for html control always null
  • HttpClient hangs when timeout is setting (Windows Phone)
  • Handle Multiple Form tag in asp.net page?
  • create word document with html content in c#
  • Confusion about Find And Replace
  • Format sms messages in Clickatell
  • Automated Function Overload
  • String to date in MS Access SQL statement gives type mismatch error
  • ShowDialog exiting on certain events
  • Is there a try Convert.ToInt32... avoiding exceptions
  • How to move wpf application into minimize tray at Window Start-up C#?
  • How to change display format of long variable?
  • How to use Addfields in MongoDB C# Aggregation Pipeline
  • MsTest TestCleanup method not called when an unhandled exception is thrown
  • missing last data when exporting gridview to excel
  • How to add array of objects to List in c#
  • Lambda Expression to order (sort) my list collection
  • Library for displaying music notation
  • How to compare two dictionaries in c# and get the output as True and False after validation
  • specify fields to be serialized with JSON
  • How do you obtain the content of a specific node using XmlDocument in C#?
  • How to ignore the first line in a csv file when you read the csv file in C#
  • c# - Problem calling public void from class
  • How to tell a class which objects it should create? Type vs. object confusion :(
  • Save CheckBox state to xml
  • WIX CAQuietExec NETSH Command Fails
  • Issues sending http put request every 60 seconds to RoR app
  • ConfigurationManager.ConnectionStrings.ConnectionString Issue
  • Real size WPF controls for printing
  • How to cancel properly?
  • C# String multiplication error
  • Using Solrnet and Assigning Attributes with Entity Framework Generated POCOs
  • Regex pattern for single backslash
  • TextBox: insert spaces for credit card number?
  • C# DLL loaded for exe-application is not found when launching similar DLL by rundll32.exe
  • Debug a Windows Service with WCF library
  • Open a file from an external assembly?
  • Servicestack RegistrationFeature Unable to bind request
  • Index was outside the bounds of the array confusion
  • Error in Xml to List code. The ':' character, hexadecimal value 0x3A, cannot be included in a name
  • I am trying to do a while loop with a string conditional statement in C#
  • C# 'Cannot access a disposed object. Object name: 'SslStream'.'
  • How to make Gecko use seperate CookieContainer per instance?
  • C# Advanced form "please wait"
  • Send and Receive data C# using network stream
  • How to discover that appsettings changed in C#?
  • Check what needs full trust
  • What is the execution order of an MVC Razor view/layout
  • Table designer (Entity Framework) is too resource intense
  • How to clean up an exception string so it can be displayed via Javascript Alert?
  • Configuring Amazon SES Feedback Notifications via Amazon SNS in ASP.NET MVC (C#)
  • C# api responce and request
  • Dynamodb putitem function not working properly
  • theme in windows phone(light or dark) using c#
  • Backup attached database file(.mdf) using c# and SQL Server
  • What is 'TextFile' and where it is uses in WPF project
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org