Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 831
Ayush choubey Avatar asked Aug 14 '26 15:08

Ayush choubey


2 Answers

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)

like image 174
Marco A. Avatar answered Aug 17 '26 05:08

Marco A.


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/

like image 31
Andrey Smorodov Avatar answered Aug 17 '26 06:08

Andrey Smorodov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!