Ayush choubey
Ayush choubey

Reputation: 616

Image Segmentation using OpenCV

I am pretty new to openCV and would like a little help

So my basic idea was to use opencv to create a small application for interior designing.

Problem

How to differentiate between walls and floor of a picture (even when we have some noise in the picture).

For Ex.enter image description here

Now, my idea was, if somehow i can find the edges of the wall or tile, and then if any object which will be used for interior decoration(for example any chair), then that object will be placed perfectly over the floor(i.e the two image gets blended)

My approach

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv/cv.h>
using namespace cv;
using namespace std;
int main(){
  Mat image=imread("/home/ayusun/Downloads/IMG_20140104_143443.jpg");
  Mat resized_img,dst,contours,detected_edges;
  resize(image, resized_img, Size(1024, 768), 0, 0, INTER_CUBIC);
  threshold(resized_img, dst, 128, 255, CV_THRESH_BINARY);
  //Canny(image,contours,10,350);

  namedWindow("resized image");
  imshow("resized image",resized_img);

  //imshow("threshold",dst);
  blur( resized_img, detected_edges, Size(2,2) );
  imshow("blurred", detected_edges);

  Canny(detected_edges,contours,10,350);
  imshow("contour",contours);
  waitKey(0);
  return 1;
}

I tried canny edge detection algorithm, but it seems to find a lot of edges. And i still don't know how to combine floor of the room with that of the chair

Thanks

Upvotes: 3

Views: 6153

Answers (3)

Rosa Gronchi
Rosa Gronchi

Reputation: 1911

Segmenting walls and floors out of a single image is possible to some extent but requires a lot of work, it will require quite a complex system if you want to achieve decent results. You can probably do much better with a pair of images (stereo reconstruction)

Upvotes: 1

Andrey  Smorodov
Andrey Smorodov

Reputation: 10852

OpenCV's POSIT may be userful for you (here is an example): http://opencv-users.1802565.n2.nabble.com/file/n6908580/main.cpp

Also take a look at augmented reality toolkits ArUco for example.

For advanced methods take a look at ptam.

And you can find some userful links and papers here: http://www.doc.ic.ac.uk/~ajd/

Upvotes: 1

Marco A.
Marco A.

Reputation: 43662

Sorry for involuntary advertisement but IKEA uses a catalog smartphone app which uses augmented reality to position objects/furniture around an image of your room. Is that what you're trying to do?

enter image description here

In order to achieve this you would need a "pinpoint", a fixed point where to hook your objects to. That usually helps differentiate between walls and floor in the app above (and renders things easy).

Distinguishing walls from floors is hard even for a human if they're hanging by their feet and walls/floors have the same texture on them (but we manage to do it thanks to our "gravity feeling").

Find some keypoints or please state if you're planning to do it with a fixed camera (i.e. it will never be put horizontally)

Upvotes: 1

Related Questions