angelkim88 / CARLA-Lane_Detection

77 stars 30 forks source link

cv2.imshow is unnormal #1

Open xia0long opened 4 years ago

xia0long commented 4 years ago

Hi!I need to create an additional window to show camera's view like u do. so I wrote code below:

# original code
image.convert(self.sensors[self.index][1])
array = np.frombuffer(image.raw_data, dtype=np.dtype("uint8"))
array = np.reshape(array, (image.height, image.width, 4))
array = array[:, :, :3]
array = array[:, :, ::-1]
self.surface = pygame.surfarray.make_surface(array.swapaxes(0, 1))

# my code
img = np.array(image.raw_data).astype('uint8')
img = img.reshape((image.height, image.width, 4))
img = img[:, :, :3].
cv2.imshow("", img)
cv2.waitKey(1)

But this code can not work normally. Mostly my code can't create a window , in a few cases it created a small window. Both window show an all white image. I checked the image‘s raw_data ,it's normal. I think this issue described a similar question. Looking forward ur reply. Thank you!

hamdii02 commented 4 years ago

@gagaxiaolong hello, have you found a solution ?

xia0long commented 4 years ago

@gagaxiaolong hello, have you found a solution ?

Nope. I just show the lane marker in origin window.

angelkim88 commented 4 years ago

@gagaxiaolong @hamdii02 Oh sorry. I have been busy these days, so I haven't paid attention to Github. This code is working on windows. The version of CARLA is 0.9.5.

To work on Ubuntu, you need to modify the code. I'll post the code I modified during today.

Harshal-Bhat commented 4 years ago

Hi I was curious about the fidelity of your code,so thought to run it once but when ever I run your code the pygame window doesn't respond and cmd gives runtimeerror:Failed to connect to new map.This maybe due to lack of computing power.how can I change for the pygame window to stay more time?

Exasor commented 4 years ago

I encoutered this issue with blank image and I changed cv2.waitKey(1) to a larger number like cv2.waitKey(30), and image appears, but I also meet an issue that the image doesn't update, that's really confusing.