eigen

Using Eigen Array-of-Arrays for RGB images

女生的网名这么多〃 提交于 2019-12-19 06:41:03
问题 I'm trying to use the Eigen library for some simple image processing. I'd use Array3f for an RGB triple and an Array to hold an RGB image. This seems to work partially, and I can conveniently do component-wise addition, multiplication and division of images. But certain operations (specifically involving subtraction or negation) seem to create compile errors. Here is a minimal example: #include <Eigen/Core> using namespace Eigen; int main(void) { typedef Array<Array3f, Dynamic, Dynamic>

Issue casting C++ Eigen::Matrix types via templates

怎甘沉沦 提交于 2019-12-19 03:17:02
问题 I'm writing a C++ function that is templated on type (either float or double ), and uses Eigen::Matrix internally. The function will be using a combination of float , double , and templated type Eigen:Matrix objects. Eigen::Matrix<>::cast() works just fine for double and float , though I'm hitting an odd issue when using it with templated types. See code below: #include "Eigen/Core" // Version 3.2.4 (eigen-eigen-10219c95fe65) template <typename Scalar> void Foo() { Eigen::Matrix<double, 3, 1>

Issue casting C++ Eigen::Matrix types via templates

允我心安 提交于 2019-12-19 03:16:22
问题 I'm writing a C++ function that is templated on type (either float or double ), and uses Eigen::Matrix internally. The function will be using a combination of float , double , and templated type Eigen:Matrix objects. Eigen::Matrix<>::cast() works just fine for double and float , though I'm hitting an odd issue when using it with templated types. See code below: #include "Eigen/Core" // Version 3.2.4 (eigen-eigen-10219c95fe65) template <typename Scalar> void Foo() { Eigen::Matrix<double, 3, 1>

Eigen - Re-orthogonalization of Rotation Matrix

ⅰ亾dé卋堺 提交于 2019-12-18 22:32:33
问题 After multiplying a lot of rotation matrices, the end result might not be a valid rotation matrix any more, due to rounding issues (de-orthogonalized) One way to re-orthogonalize is to follow these steps: Convert the rotation matrix to an axis-angle representation (link) Convert back the axis-angle to a rotation matrix (link) Is there something in Eigen library that does the same thing by hiding all the details? Or is there any better recipe? This procedure has to be handled with care due to

Using Eigen Library with OpenCV 2.3.1

这一生的挚爱 提交于 2019-12-18 16:12:09
问题 I have trouble in using Eigen3 Library along with OpenCV application in C++ . I have installed Eigen3 library on my Ubuntu using the following command: sudo apt-get install libeigen3-dev I am able to compile and use sample Eigen3 applications (Eigen3 library is installed and it works) when I use the following command to compile. g++ -I/usr/include/eigen3 Eig.cpp -o Eig I want to use the installed Eigen library with OpenCV. I compiled OpenCV source with following flags: cmake -D WITH_TBB=ON -D

How to write a matrix matrix product that can compete with Eigen?

佐手、 提交于 2019-12-18 10:57:07
问题 Below is the C++ implementation comparing the time taken by Eigen and For Loop to perform matrix-matrix products. The For loop has been optimised to minimise cache misses. The for loop is faster than Eigen initially but then eventually becomes slower (upto a factor of 2 for 500 by 500 matrices). What else should I do to compete with Eigen? Is blocking the reason for the better Eigen performance? If so, how should I go about adding blocking to the for loop? #include<iostream> #include<Eigen

Initialize an Eigen::MatrixXd from a 2d std::vector

妖精的绣舞 提交于 2019-12-18 10:56:47
问题 This should hopefully be pretty simple but i cannot find a way to do it in the Eigen documentation. Say i have a 2D vector, ie std::vector<std::vector<double> > data Assume it is filled with 10 x 4 data set. How can I use this data to fill out an Eigen::MatrixXd mat . The obvious way is to use a for loop like this: #Pseudo code Eigen::MatrixXd mat(10, 4); for i : 1 -> 10 mat(i, 0) = data[i][0]; mat(i, 1) = data[i][1]; ... end But there should be a better way that is native to Eigen? 回答1: Sure

Conflict between Boost, OpenCV and Eigen libraries?

落爺英雄遲暮 提交于 2019-12-18 05:54:16
问题 my question is somewhat related to Static linking of Boost and OpenCV libs with Eclipse CDR. errors, whereas I'm trying to do a bit more than described here: How to create a program that can read all the images in folder using Boost and OpenCV?, namely traverse a directory using Boost's filesystem library and do some processing on the image files with OpenCV. I compiled filesystem and other libraries with MinGW, and try to run Boost 1.45, OpenCV 2.2 and Eigen2 with Eclipse CDT on a Windows 7

how to use Boost:serialization to save Eigen::Matrix

流过昼夜 提交于 2019-12-18 04:21:50
问题 Hello I have a code which implements libeigen2 to calculate eigen vectors. Now I want to use boost::serialization to save the information for retrieving later. From the example tutorial I came up with the following code! class RandomNode { private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & is_leaf_; ar & depth_; ar & num_classes_; ar & num_features_; // Split node members ar & random_feature_indices_; ar

Eigen boolean array slicing

Deadly 提交于 2019-12-18 03:36:13
问题 In MATLAB it is common to slice out values that satisfy some condition from a matrix/array (called logical indexing). vec = [1 2 3 4 5]; condition = vec > 3; vec(condition) = 3; How do I do this in Eigen? So far I have: Eigen::Matrix<bool, 1, 5> condition = vec.array() > 3; 回答1: As pointed out in the answer to an similar question here: Submatrices and indices using Eigen, libigl adds this functionality to Eigen. igl::slice(A,indices,B); Is equivalent to B = A(indices) 回答2: Try this: #include