Ask Your Question

Pat's profile - activity

2020-09-28 10:44:14 -0600 received badge  Popular Question (source)
2016-04-19 06:20:05 -0600 received badge  Famous Question (source)
2015-03-07 07:14:49 -0600 received badge  Notable Question (source)
2014-11-29 07:05:42 -0600 received badge  Good Question (source)
2014-08-12 09:23:05 -0600 received badge  Popular Question (source)
2012-08-24 09:46:54 -0600 commented answer Image shuffle not working

Yes, I did that and it works now. I just assumed that if I use regular affectation of ROI openCV would only copy the region and not just the pointer. Thanks.

2012-08-22 14:08:40 -0600 commented question Is stereoRectifyUncalibrated efficient?

The one implemented in MatLab could very well use subroutines written in Fortran or C, so their function implementation using a different algorithm could possibly be faster than openCV's implementation.

2012-08-21 12:51:51 -0600 asked a question Image shuffle not working

I know for a fact that the image I receive in the arguments method is correct, because if I omit the shuffle I get the image displayed correctly.

When I use this function the resulting image is exactly the same, as if nothing had been done. I'm not sure if I am handling the ROI copies correctly :

void OpenCvHandler::shuffleImage(cv::Mat &image)
{
int topX = 0, topY = 0, randX = 0, randY = 0;
std::vector<Pair> pile;

while(pile.size() < (PUZZLE_TILE_NUMBER * PUZZLE_TILE_NUMBER))
{
    do
    {
        randX = PUZZLE_MASK_DIMS;
        randY = PUZZLE_MASK_DIMS;
        randX *= rand() % PUZZLE_TILE_NUMBER;
        randY *= rand() % PUZZLE_TILE_NUMBER;
    }
    while( pairWithinVector(pile, randX, randY) );

    cv::Mat src = image(cv::Rect(topX, topY, PUZZLE_MASK_DIMS, PUZZLE_MASK_DIMS));
    cv::Mat dst = image(cv::Rect(randX, randY, PUZZLE_MASK_DIMS, PUZZLE_MASK_DIMS));
    cv::Mat tmp;
    dst.copyTo(tmp);
    dst = src;
    src = tmp;

    pile.push_back(Pair(randX, randY));
    topX += PUZZLE_MASK_DIMS;

    if(topX == PUZZLE_DIMS)
    {
        topY += PUZZLE_MASK_DIMS;
        topX = 0;
    }
}
}

Here are the values of the constants I use :

static const int PUZZLE_TILE_NUMBER = 3;
static const int PUZZLE_MASK_DIMS = 260;
static const int PUZZLE_DIMS = PUZZLE_TILE_NUMBER * PUZZLE_MASK_DIMS;

Essentially with these values I copy tiles of 260x260 in different parts of the image and copy the destination image to where the copied image once was.

2012-07-25 21:27:34 -0600 asked a question How to give ownership of Mat data to other structure

I'm using OpenCV and SDL in tandem, I've declared a Mat in a function and once I'm done with it I give it's data to create an SDL_Surface, I'm assuming that once we leave the function scope the mat is recycled? I'm getting an access violation as soon as I use the sdl_surface and the data it contains is garbage.

I can also say that the function SDL_CreateRGBSurfaceFrom doesn't copy the data it uses what's stored at the pointer location.

Here's the function, I haven't written C++ in a while so perhaps I'm making a big mistake: http://pastie.org/4333990

2012-07-25 03:32:21 -0600 received badge  Nice Question (source)
2012-07-25 02:42:45 -0600 received badge  Student (source)
2012-07-24 21:52:55 -0600 received badge  Editor (source)
2012-07-24 21:52:29 -0600 asked a question Matrix depth equals 0

If I do the following :

cv::Mat image = imread("someImage.bmp");

cv::Mat dst;

image.copyTo(dst);

int depth = dst.depth()//dst has a depth of 0

I'm not sure I follow why the depth is zero, according to the doc copyTo does(Before the copy):

dst.create(this->size(), this->type);

Doesn't the type tell the depth since it's likely CV_8UC3?

Otherwise how should I make dst have the same properties as 'image' after a copyTo? I'm asking because I've hard-coded the depth to 8 in my code and it works fine, so I just need to match the settings of the first mat to the second one. The create function only takes rows, cols and type. I assumed giving it the type would be enough for the mat to figure out it's depth. The channels() is set properly to 3.

2012-07-24 20:47:52 -0600 commented answer Saving an image with unset pixels

Thanks Martin, this has shed some light and it makes sense. I actually have more questions now though hehe.

2012-07-23 16:58:23 -0600 asked a question Saving an image with unset pixels

What happens during imwrite if you specify a png image and that the passed mat has unset pixels? Are they treated as no opacity pixels? Because when I save I still get the gray value, so perhaps when I create a cv::Mat is it filled in gray by default?

2012-07-21 20:41:30 -0600 received badge  Scholar (source)
2012-07-21 15:33:36 -0600 asked a question Mask + Image without black on destination

Hi, essentially I have a mask and I make a bitwise_and between the mask and an image. This works wonderfully, but I cannot find a way to ignore the black on the destination image. Here's the process for more clarification :

http://img.photobucket.com/albums/v220/jaeko/mask.png

Essentially, I do something like this:

//Should dst have an alpha channel to replace black by a zero-opacity pixel?
cv::bitwise_and(image, mask, dst, mask???);
2012-07-21 15:32:59 -0600 asked a question Use border as mask then remove black

Hi, essentially I have a mask and I make a bitwise_and between the mask and an image. This works wonderfully, but I cannot find a way to ignore the black on the destination image. Here's the process for more clarification :

http://img.photobucket.com/albums/v220/jaeko/mask.png

Essentially, I do something like this:

//Should result have an alpha channel to replace black by a zero-opacity pixel?
cv::bitwise_and(image, mask, image, mask???);