Ask Your Question

mtourne's profile - activity

2015-12-12 14:36:48 -0600 received badge  Nice Answer (source)
2015-12-12 14:36:18 -0600 received badge  Good Question (source)
2015-03-01 11:02:23 -0600 commented question Latent SVM - training from opencv_extras

I feel like you're not really answering the question.

2015-02-27 22:03:27 -0600 asked a question Latent SVM - training from opencv_extras


I'm using the sample code for latentsvm detector [1]. It's from opencv 2.4, this sample code actually seems to be gone in the master branch (?)

I'm using what seems to a be a pretrained model on VOC2007 [2], I'm only using the cars.xml model not all of them.

Here is the output of running the car detector on a picture of a cat :

It did an ok job at finding cars :

But then again, everything appears to be a car ..



2014-07-01 14:30:12 -0600 received badge  Teacher (source)
2014-02-20 10:14:37 -0600 commented question FileStorage and (smart) pointers

added a code snippet, not sure it conveys more than the text though

2014-02-19 23:17:46 -0600 asked a question FileStorage and (smart) pointers


I've created a class Image which is a wrapper over a Mat (the actual data), plus some keypoints, descriptors, camera intrinsic matrix, etc .. I have an Image::ptr which is a shared_ptr<image>

I have vectors of Image::ptr, pairs of Image::ptr. Everybody is sharing, everything is great!

Up until I serialize // deserialize them using FileStorage.

Not surprisingly the serialized file contains a copy of the data, in every place I've used an Image::ptr. The more problematic thing, is that if I de-serialize I now have a copy of my Image everytime it appeared in a vector. (I don't serialize the actual pixels, just descriptors but still).

The question is, Is there a way to deal with smart / auto ptr to avoid redundancy when serializing ?

Otherwise, I'm considering using a global variable holding a map<index,image::ptr> and then replace Image::ptr with index everywhere. Or is there a simpler cleaner way that I haven't seen ?

Thank you!

EDIT: adding code snippet

class Image {
  typedef shared_ptr<Image> ptr;

  Mat data;
  vector<Keypoint> Keypoints;
  Mat descriptors;

Image::ptr img1 (new Image());
Image::ptr img2 (new Image());

pair<Image::ptr, Image::ptr>> image_matches1;
pair<Image::ptr, Image::ptr>> image_matches2;

// note that it's the same pair
image_matches1 = make_pair(img1, im2);
image_matches2 = make_pair(img2, im1);

// prints out the same pointer, which makes sense
cout << image_matches1.first() << endl;
cout << image_matches2.second() << endl;

// serialization
FileStorage fsb("filestorage_pairs.txt", FileStorage::WRITE);
 fsb << "pair1" << img_matches1;
 fsb << "pair2" << img_matches2;

// de-serialization"filestorage_pairs.txt", FileStorage::READ);

ImagePair pair1_loaded;
ImagePair pair2_loaded;

 fsb["pair1"] >> pair1_loaded;
 fsb["pair2"] >> pair2_loaded;

// now the pointers are different, through serializaion / deserialization the resource has been copied
cout << pair1_loaded.first() << end;
cout << pair2_loaded.second() << end;
2013-12-23 03:06:32 -0600 commented answer Find a small square patch inside an "approxPolyDP" polygon

My next idea was to apply a distance transform on the masked version, then threshold to get a local max. This should get me a patch towards the center of the texture. I imagine the distance transform is more expensive ?

2013-12-22 04:59:56 -0600 received badge  Self-Learner (source)
2013-12-22 03:21:37 -0600 asked a question Find a small square patch inside an "approxPolyDP" polygon


I'm processing a still image in order to find where the water is. (see my other question here)

Now, I can find all the rather large polygons in the image, using approxPolyDP. But there is no guarantee that the water is the dominant part of the image.

In case I have a few large-ish polygons (> 5%) of the image), I'd like to find a small patch that fits in my polygon and test its texture using one of the classic statistical texture methods (local binary pattern, laws, gabor filters).

But I'm not sure how to find a small square that fits inside the polygon. The only thing I can think of is to use the center of gravity, and create a small box around it. But in the case of a complicated shape, the center of gravity might not be in the shape itself.

Here is an example where finding a small square patch in the polygon that I have outlined seems potentially tricky:

Original image:

Original image

Outline of the water (one of the large polygons), where I'd like to define a square patch :

Water mask

2013-12-22 02:53:48 -0600 answered a question Filtering out coast line

I finally ended up inverting the edges found with the canny procedure and applying findContours on that, to cut on the number of steps. It roughly looks like that :

edge = cv2.Canny(img_gray, CANNY_THRSH_LOW, CANNY_THRSH_HIGH, apertureSize=5)
kern = np.ones((5, 5))
# dilatation connects most of the disparate edges
edge = cv2.dilate(edge, kern)
# invert edges to create one big water blob
edge_inv = np.zeros((img_gray.shape), np.uint8)
edge_inv = edge_inv - edge
contours0, hierarchy0 = cv2.findContours(edge_inv.copy(), cv2.RETR_EXTERNAL,
2013-12-10 11:37:39 -0600 commented answer Filtering out coast line

That makes sense, thank you!

2013-12-10 04:02:30 -0600 received badge  Nice Question (source)
2013-12-10 02:23:59 -0600 commented answer Filtering out coast line

Did you use a trackbar to change the value for the threshold in practice ? I can't seem to replicate your result using the value "10" for the threshold

2013-12-10 02:07:58 -0600 received badge  Scholar (source)
2013-12-10 02:07:56 -0600 received badge  Supporter (source)
2013-12-09 04:22:06 -0600 received badge  Student (source)
2013-12-09 01:01:15 -0600 received badge  Editor (source)
2013-12-09 01:00:42 -0600 asked a question Filtering out coast line


In the context of flying over water, I'm trying to segment the coastline out of the water.

To do that I've been using a Canny edge detection, which I'm hoping to use to create several large polygons : Each polygon should be contain either: the coastline, the body of water, or some other occlusion

My problem is that I can't find a way to connect a line to the "borders of the image" and make a polygon that way.

What I currently have produces this image : On the top left, and the right is a coastline (flying over a bay), and the bottom part is the UAV itself with the antenna.

This is almost what I need, but I need to create a polygon that extends all the way to the borders. image description

This is the code :

def find_coastline(img_gray, img_rgb):
    CANNY_THRSH_LOW = 1000
    # add borders for polygons
    edge = cv2.Canny(img_gray, CANNY_THRSH_LOW, CANNY_THRSH_HIGH, apertureSize=5)
    kern = np.ones((5, 5))
    # dilatation connects most of the disparate edges
    edge = cv2.dilate(edge, kern)
    vis = cv2.cvtColor(img_gray, cv2.COLOR_GRAY2BGR)
    vis[edge != 0] = (0, 255, 0)
    cv2.imwrite('boats_canny.jpg', vis)
    # only external contours
    contours, hierarchy = cv2.findContours(edge.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
    vis = np.zeros((img_rgb.shape), np.uint8)
    i = 0
    for cnt in contours:
        color = np.random.random_integers(255, size=(3))
        cv2.drawContours( vis, contours0, i, color,
                          3, cv2.CV_AA, hierarchy, 0)
        i += 1
    cv2.imwrite('boats_contours.jpg', vis)

This is the original image : image description