imshow seems to show the wrong image -
i using code load/show/write images (opencv_python-3.3.0-cp36-cp36m-win32):
import cv2 img0 = cv2.imread('original.jpg',1) img1=img0 in range(img0.shape[0]): j in range(img0.shape[1]): img1[i,j]=[0,0,255] cv2.imshow('original',img0) cv2.waitkey(0) cv2.destroyallwindows()
note line 7 supposed show original image img0, shows modified image img1 instead (i.e. red rectangle). line 3 supposed create temporary copy of img0, not modify img0. wrong here?
when using assignment operator (=) between mat variables, not copying data sharing reference. hence change in 1 getting reflected in another. please checkout : http://docs.opencv.org/2.4/modules/core/doc/basic_structures.html#mat-operator
you need use clone() or copyto() achieve want. check them out here : http://docs.opencv.org/2.4/modules/core/doc/basic_structures.html#mat-clone
Comments
Post a Comment