Ask Your Question

SPV_86's profile - activity

2014-08-20 04:01:21 -0600 commented question No EM in the official GIT repository

Yes, but since that repository was the one indicated in the windows compilation manual, I was a bit puzzled not to find this, since I thought it was a stable branch. Thanks BTW.

2014-08-20 03:11:13 -0600 received badge  Editor (source)
2014-08-20 03:10:26 -0600 asked a question Changing pyopencv_generated_types.h

Hi,

I've noticed a bug:

In the line 5113 of the file pyopencv_generated_types.h (code of the version 2.4.9 from sourceforge)

it says:

Mat covs0;

Whe it should say:

std::vector<mat> covs0;

Mat is the wrong type for covs since covs should be a list of covariace matrices (and there is an assertion to check that) but from python the users are not allowed to pass such list of matrices, if the type isn't changed to std::vector<Mat>.

Since the file pyopencv_generated_types.h is generated automatically, I want to know what to change to generate this file with the correct type.

thanks.

2014-08-20 03:05:03 -0600 asked a question No EM in the official GIT repository

Hello,

When I compile the "Offical" git code («https://github.com/Itseez/opencv.git» "Master" branch), there is no EM wrap in the resulting cv2.pyd python file.

How do I change it / include it?

2014-05-26 05:25:43 -0600 received badge  Student (source)
2014-05-26 02:57:05 -0600 asked a question Understanding the use of EM

Hello,

I am trying to use EM to detect objects in a picture using python. My first problem is that the official documentation is not very descriptive of what the input should be.

This is my code so far:

import numpy as np
import cv2

#Image read
imgpath='.\TestImages\CloudsEasy.jpg'
sample = cv2.imread(imgpath)[:,:,1]
image_rows = np.size(sample,0)
image_cols = np.size(sample,1)
#flatten sample
sample_flat = sample.flatten()*(1.0 / 255.0)

#EM training
print('training...')
n_clusters=10;
em = cv2.EM(n_clusters)

log_likelihoods = np.zeros(shape=(image_rows * image_cols,1))
labels = np.zeros(shape=(image_rows * image_cols,1))
probs = np.zeros(shape=(image_rows * image_cols, n_clusters))

trained = em.train(sample_flat, log_likelihoods, labels, probs)
print('Trained? ->'+ str(trained[0]))

I have seen exactly what I want to do but in C++ Here. The example seems to send a matrix with the picture x, y combinations and no image value for the tuple. This is confusing for me since I'm starting.

Can anybody please tell me what is the exact input for the training. Some good documentation would be much appreciated as well.

Thanks in advance.