How to compare two images in JavaCV and draw rectangles the part which is different in these two images -


i want compare 2 images using javacv, , draw rectagle in part these images not same example below.

enter image description here

i tried code below, needs 1 image input, , draw rectangle on objects in image.

iplimage img=cvloadimage("image_path_and_name.jpg");         cvsize cvsize = cvsize(img.width(), img.height());         iplimage gry=cvcreateimage(cvsize, img.depth(), 1);         cvcvtcolor(img, gry, cv_bgr2gray);         cvthreshold(gry, gry, 200, 255, cv_thresh_binary);         cvadaptivethreshold(gry, gry, 255, cv_adaptive_thresh_mean_c, cv_thresh_binary_inv, 11, 5);          cvmemstorage storage = cvmemstorage.create();         cvseq contours = new cvcontour(null);          int noofcontors = cvfindcontours(gry, storage, contours, loader.sizeof(cvcontour.class), cv_retr_ccomp, cv_chain_approx_none, new cvpoint(0,0));          cvseq ptr = new cvseq();          int count =1;         cvpoint p1 = new cvpoint(0,0),p2 = new cvpoint(0,0);          (ptr = contours; ptr != null; ptr = ptr.h_next()) {              cvscalar color = cvscalar.blue;             cvrect sq = cvboundingrect(ptr, 0);                  system.out.println("contour no ="+count);                 system.out.println("x ="+ sq.x()+" y="+ sq.y());                 system.out.println("height ="+sq.height()+" width ="+sq.width());                 system.out.println("");                  p1.x(sq.x());                 p2.x(sq.x()+sq.width());                 p1.y(sq.y());                 p2.y(sq.y()+sq.height());                 cvrectangle(img, p1,p2, cv_rgb(255, 0, 0), 2, 8, 0);                 cvdrawcontours(img, ptr, color, cv_rgb(0,0,0), -1, cv_filled, 8, cvpoint(0,0));                 count++;          }          cvshowimage("contures",img);         cvwaitkey(0) 

;

output:

enter image description here

if 1 knows how this, please let me know. in advance!


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -