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

Something is wrong with the Message when running the demo #211

Open
pylpyl opened this issue Jul 15, 2021 · 0 comments
Open

Something is wrong with the Message when running the demo #211

pylpyl opened this issue Jul 15, 2021 · 0 comments

Comments

@pylpyl
Copy link

pylpyl commented Jul 15, 2021

  • Operating System: Ubuntu 20.04
  • UE4 Version: 4.5
  • UnrealCV Version: 0.4.0
  • Client (python2, 3 or matlab): python 2.7
  • Problem Description:

I installed the unrealcv and tried to run the demos.
First, I started the RealisticRendering game with ./playground. Then I ran the following code:

from unrealcv import client
client.connect() # Connect to the game
if not client.isconnected(): # Check if the connection is successfully established
print('UnrealCV server is not running. Run the game from http://unrealcv.github.io first.')
else:
print('Connected.')
filename = client.request('vget /camera/0/lit')

This simple demo can run successfully. As a result, a png figure of the game scene is saved to 'RealisticRendering/LinuxNoEditor/RealisticRendering/Binaries/Linux'. So, it seems that the environment in which I'm running the demo is correct.

However, I don't want to save the image to the hard disk. Instead, I'd like to transfer the image from the server to my algrithm directly. I read your Command List and noticed that the command

vget /camera/0/lit

which I used just now will store the image to the disk. But the command

vget /camera/0/lit png

can return the binary date through socket instead of saving it.
Moreover, I also noticed that in your faster_rcnn.py demo the above mentioned command is use in

res = client.request('vget /camera/0/lit png')

I just want to test this command, so I replaced the faster rcnn part with a function which takes in a image and return it immediately:

def faster_rcnn_detect(ax, frame):
return frame

Except for this modification, the complete code is mainly copied from the communication part of the faster_rcnn.py:

def faster_rcnn_detect(ax, frame):
return frame
def main(img_processor):
def capture_frame(func=None):
res = client.request('vget /camera/0/lit png')
im = read_png(res)
return im
def updatefig(*args):
frame = capture_frame(img_processor)
img_processor(ax, frame)
fig.canvas.draw()
return ax,
fig = plt.figure()
client.connect()
ani = animation.FuncAnimation(fig, updatefig, interval=50, blit=True)
fig, ax = plt.subplots()
plt.axis('off')
plt.tight_layout()
plt.show()
if name == 'main':
main(faster_rcnn_detect)

It is supposed to show the image of the current game scene when I clicked mouse in the game window.
However, the program crashed when I clicked in the game.
I printed the messages between server and client. Before clicking mouse, the client keeps sending messages like:

1:vget /camera/0/lit png
2:vget /camera/0/lit png
3:vget /camera/0/lit png

and receiving long messages seem like binary data.
But once clicked, the received message is:

clicked

It is strange because it does not match the [message_id:message_body] structure. This message can not be parsed so the demo crashed.
Why can't I receive correct message when clicked the mouse?

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

1 participant