Vision sensor img

Report crashes, strange behaviour, or apparent bugs
Post Reply
Posts: 8
Joined: 15 Sep 2021, 07:40

Vision sensor img

Post by lyl »

Traceback (most recent call last):
File "C:\python\coppeliasim1\", line 33, in <module>
NameError: name 'buffer' is not defined
This error occurred in my code when I was using the Python remote API to get a visual sensor. The visual sensor properties are shown in pictures.


Code: Select all

import sim
import sys
import numpy as np
import math
import matplotlib.pyplot as mpl
import time
import pygame
import cv2
##### Python connect to the V-REP client

print('Program started')
# Close potential connections

clientID = sim.simxStart('', 19997, True, True, 5000, 5)
print("Connection success")

# Start simulation
sim.simxStartSimulation(clientID, sim.simx_opmode_blocking)
print("Simulation start")

##### Obtain the handle
errorCode,visionSensorHandle = sim.simxGetObjectHandle(clientID,'Cam',sim.simx_opmode_oneshot_wait)

##### Get the image of vision sensor
errorCode,resolution,image = sim.simxGetVisionSensorImage(clientID,visionSensorHandle,0,sim.simx_opmode_streaming)
errorCode,resolution,image = sim.simxGetVisionSensorImage(clientID,visionSensorHandle,0,sim.simx_opmode_buffer)

#Process the image to the format (64,64,3)
sensorImage = []
sensorImage = np.array(image,dtype = np.uint8)

#Use matplotlib.imshow to show the image

Posts: 837
Joined: 09 Sep 2013, 19:28

Re: Vision sensor img

Post by fferri »

The error message is pretty clear: there is no such variable named "buffer".

What is print(buffer) doing there?

Post Reply