Created by
erdisayar
| import numpy as np
from nrp_core import *
from nrp_core.data.nrp_json import *
from nrp_core.data.nrp_protobuf import *
@EngineDataPack(keyword='camera', id=DataPackIdentifier('husky_camera::camera', 'gazebo'))
@TransceiverFunction("tensorflow_python_json_engine")
def forward_image_to_engine(camera):
image_datapack = JsonDataPack("input_image", "tensorflow_python_json_engine")
if not camera.isEmpty():
cv_image = np.frombuffer(camera.data.imageData, np.uint8)
image_datapack.data['imageHeight'] = camera.data.imageHeight
image_datapack.data['imageWidth'] = camera.data.imageWidth
image_datapack.data['channel'] = 3 # RGB Image
image_datapack.data['image'] = cv_image.flatten().tolist()
return [image_datapack]
|