forked from nemilya/vrep-api-python-opencv
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimple_image_retranslate.py
More file actions
33 lines (25 loc) · 1.01 KB
/
simple_image_retranslate.py
File metadata and controls
33 lines (25 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# simple_image_retranslate.py
#
# Demo of simple image retranslate from v0 to v1
import vrep
import time
vrep.simxFinish(-1)
clientID = vrep.simxStart('127.0.0.1', 19997, True, True, 5000, 5)
if clientID!=-1:
print 'Connected to remote API server'
# get vision sensor objects
res, v0 = vrep.simxGetObjectHandle(clientID, 'v0', vrep.simx_opmode_oneshot_wait)
res, v1 = vrep.simxGetObjectHandle(clientID, 'v1', vrep.simx_opmode_oneshot_wait)
err, resolution, image = vrep.simxGetVisionSensorImage(clientID, v0, 0, vrep.simx_opmode_streaming)
time.sleep(1)
while (vrep.simxGetConnectionId(clientID) != -1):
err, resolution, image = vrep.simxGetVisionSensorImage(clientID, v0, 0, vrep.simx_opmode_buffer)
if err == vrep.simx_return_ok:
vrep.simxSetVisionSensorImage(clientID, v1, image, 0, vrep.simx_opmode_oneshot)
elif err == vrep.simx_return_novalue_flag:
print "no image yet"
else:
print err
else:
print "Failed to connect to remote API Server"
vrep.simxFinish(clientID)