class A:
def __init__(self, img):
self.img = img
def show(self):
cv2.imshow(self.img)
cv2.waitKey(33)
class B:
def __init__(self):
...
self.img = np.((1,1,1),np.uin8)
self.painter = A(self.img)
def getImg(self):
whille True:
_, self.img = cv2.read()
self.painter.show()
import cv2
class A:
def __init__(self, img):
self.img = img
def show(self):
cv2.imshow( 'image', self.img)
cv2.waitKey(3300)
if __name__ == '__main__':
img = cv2.imread('Capture.JPG')
a = a(img)
a.show()
ie not inside A need to have this img well, plus learn from In dependence from class A, and to transfer this dependence is only on the stage, create an instance
B(A())
- aisha_Watsi commented on April 19th 20 at 12:55will try to simplistically explain how it works in python
1. np.((1,1,1),np.uin8) - that's "memory"
2. self.img = np.((1,1,1),np.uin8) - this is eksemplar.img points to the "memory location"
3. A(self.img) - this will create the class object A where PCs.img points to the "memory location"
4 _, self.img = cv2.read() - this is eksemplar.img points to the new "memory"
5. self.painter.show() - this is use PCs.img, which is still pointing to the old "memory" - aisha_Watsi commented on April 19th 20 at 13:16
After him, and do not see the connection classes. There should be an inheritance or something? - Enola65 commented on April 19th 20 at 13:40
Or inheritance, to use or let about "design patterns" reads. Or here's a minimal version:
- Enola65 commented on April 19th 20 at 13:52