Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to solve TypeError: Expected Ptr<cv::UMat> for argument 'img'? #86

Open
calvin-valtz opened this issue Dec 7, 2020 · 2 comments
Open

Comments

@calvin-valtz
Copy link

calvin-valtz commented Dec 7, 2020

I get the following error
TypeError: Expected Ptr<cv::UMat> for argument 'img'
the error is in the utils.py file in line 193

186 def draw_homography_points(img, x, resize=256, color=(255,0,0)):
187 y_start1 = (0.3+x[2])(resize-1)
188 y_start = 0.3
(resize-1)
189 y_stop = resize-1
190 src = np.float32([[0.45*(2resize-1),y_start],[0.55(2resize-1), y_start],[0.1(2resize-1),y_stop],[0.9(2resize-1), y_stop]])
191 dst = np.float32([[(0.45+x[0])
(2resize-1), y_start1],[(0.55+x[1])(2resize-1), y_start1],[(0.45+x[0])(2resize-1), y_stop],[(0.55+x[1])(2resize-1),y_stop]])
192 dst_ideal = np.float32([[0.45
(2resize-1), y_start],[0.55(2resize-1), y_start],[0.45(2resize-1), y_stop],[0.55(2*resize-1),y_stop]])
193 [cv2.circle(np.assarray(img), tuple(idx), radius=5, thickness=-1, color=(255,0,0)) for idx in src]
194 [cv2.circle(np.assarray(img), tuple(idx), radius=5, thickness=-1, color=(0,255,0)) for idx in dst_ideal]
195 [cv2.circle(np.assarray(img), tuple(idx), radius=5, thickness=-1, color=(0,0,255)) for idx in dst]

196 return img

I try to browse someone with similar error with me in other forums but i still can't solve the error. I try to change cv2.circle(np.assarray(img) into cv2.circle(np.float32(img), and then to cv2.circle(np.asarray(img, dtype=np.float32)) but the problem still not solved.
Does anyone have an idea? Does it because the difference of system version?

I'm using Python 3, Tensorflow 2.4.0-rc3, PyTorch 1.7+cu11.0

@gucasbrg
Copy link

move

mask = torch.prod(gt_params != 0, 1).byte()

to

 mask = torch.prod(gt_params != 0, 1).bool()

@ayushupneja
Copy link

The above solution didn't work, did you ever solve this problem? I'm having the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants