CoppeliaSim 4.3.0 User Manual - CoppeliaSim 4.3.0 使用者手冊

  • Home
    • Site Map
    • reveal
    • blog
  • welcome
  • userInterface
    • pagesAndViews
    • coordinateDialog
    • positionDialog
    • orientationDialog
    • objectMovement
    • positionOrientationTransformation
    • settings
    • shortcuts
  • scenesAndModels
    • scenes
    • models
    • modelDialog
  • environment
    • environmentPropertiesDialog
    • textureDialog
  • entities
    • collections
    • objects
      • sceneObjectPropertiesDialog
      • commonPropertiesDialog
    • collidableObjects
    • measurableObjects
    • detectableObjects
    • viewableObjects
    • convexHull
    • layerSelectionDialog
      • cameras
      • cameraPropertiesDialog
      • lights
      • lightPropertiesDialog
      • shapes
      • shapeReferenceFrames
      • primitiveShapes
      • convexDecomposition
      • shapeProperties
      • shapeDynamicsProperties
      • shapeDynamicEngineProperties
      • geometryDialog
      • shapeEditModes
      • triangleEditMode
      • vertexEditMode
      • edgeEditMode
      • groupedShapeEditMode
      • joints
      • jointModes
      • jointProperties
      • jointDynamicsProperties
      • jointDynamicEngineProperties
      • dummies
      • dummyPropertiesDialog
      • graphs
      • graphPropertiesDialog
      • proximitySensors
      • proximitySensorDescription
      • proximitySensorPropertiesDialog
      • proximitySensorVolumeDialog
      • proximitySensorDetectionParameterDialog
      • visionSensors
      • visionSensorDescription
      • visionSensorPropertiesDialog
      • forceSensors
      • forceSensorPropertiesDialog
      • octrees
      • octreePropertiesDialog
      • pointClouds
      • pointCloudPropertiesDialog
    • paths
  • functionality
    • geometricCalculations
    • collisionDetection
    • distanceCalculation
      • geometricPlugin
      • simGeom API
      • coppeliaGeometricRoutines
      • CoppeliaGeometricRoutinesAPI
    • IGLPluginAPIreference
    • kinematics
    • basicsOnIkGroupsAndIkElements
    • solvingIkAndFk
      • kinematicsPlugin
      • simIKAPI
      • coppeliaKinematicsRoutines
      • CoppeliaKinematicsRoutinesAPI
    • dynamicsModule
    • designingDynamicSimulations
      • dynamicsDialog
      • dynamicsEngineDialog
    • dataVisualizationAndOutput
    • externalFrontEnd
    • dataTransformation
    • meansOfCommunication
      • remoteApiOverview
      • zmqRemoteApiOverview
      • wsRemoteApiOverview
      • rosInterfaces
      • rosInterf
      • ROSPluginAPIreference
      • ros2Interface
      • ROS2PluginAPIreference
    • ZMQPluginAPIreference
    • WSPluginAPIreference
    • pathsAndTrajectories
    • pathAndMotionPlanningModules
    • OMPLPluginAPIreference
    • syntheticVision
    • IMPluginAPIreference
    • simVisionAPI
    • customUIPlugin
    • UIPluginAPIreference
    • simUI-widgets
    • QMLPluginAPIreference
    • importExport
    • xmlFormat
      • urdfPlugin
      • APIFunctions
      • sdfPlugin
      • SDFPluginAPIreference
    • aviRecorder
    • AssimpPluginAPIreference
    • GLTFPluginAPIreference
      • commandLine
      • LuaCmdPluginAPIreference
      • miscellaneousFunctionality
      • SurfRecPluginAPIreference
      • ICPPluginAPIreference
      • SubprocessPluginAPIreference
  • writingCode
    • scripts
      • embeddedScripts
      • simulationScripts
      • mainScript
      • childScripts
      • customizationScripts
      • scriptProperties
      • scriptEditor
    • addOns
    • sandboxScript
    • scriptExecution
    • threadedAndNonThreadedCode
      • callbackFunctions
      • dynCallbackFunctions
      • jointCallbackFunctions
      • contactCallbackFunction
      • visionCallbackFunctions
      • triggerCallbackFunctions
      • userConfigCallbackFunctions
    • luaPythonDifferences
    • luaCrashCourse
    • plugins
    • mainClientApplication
    • accessingSceneObjects
    • explicitHandling
    • apisOverview
      • apiFunctions
      • apiConstants
      • objectParameterIDs
  • simulation
    • simulationPropertiesDialog
  • tutorials
    • bubbleRobTutorial
    • buildingAModelTutorial
    • lineFollowingBubbleRobTutorial
    • inverseKinematicsTutorial
    • externalControllerTutorial
    • pluginTutorial
    • robotLanguageIntegrationTutorial
    • rosTutorial
      • ros1Tutorial
      • ros2Tutorial
    • compilingCoppeliaSim
OMPLPluginAPIreference << Previous Next >> IMPluginAPIreference

syntheticVision

Synthetic vision

Synthetic vision is achieved in CoppeliaSim via vision sensors: they can perform offscreen rendering of the scene in different modes. The generated image can then be modified/processed in various ways, for instance from within a vision callback function:

  • image processing with OpenCV (via the image plugin)
  • simple image processing via the vision plugin
  • sim.transformImage
  • sim.transformBuffer
  • Following shows a vision callback function that illustrates 3 different ways to modify an acquired image:

    function sysCall_vision(inData)
        -- inData.handle: handle of the vision sensor
        -- inData.resolution: resolution of the vision sensor
        -- inData.clippingPlanes: near and far clipping plane of the vision sensor
        -- inData.viewAngle: the view angle if the vision sensor is in perspective operation
        -- inData.orthoSize: the size of the view if the vision sensor is in orthogonal operation
        -- inData.perspectiveOperation: whether the vision sensor is in perspective operation
    
        -- e.g. use very simple functions from the vision plugin (simExtVision):
        simVision.sensorImgToWorkImg(inData.handle)
        simVision.edgeDetectionOnWorkImg(inData.handle,0.2)
        simVision.swapWorkImgWithBuffer1(inData.handle)
        simVision.uniformImgToWorkImg(inData.handle,{0.5,0.25,0})
        simVision.addBuffer1ToWorkImg(inData.handle)
        simVision.workImgToSensorImg(inData.handle)
        
        -- and/or, use more powerful functions from the image plugin (simExtImage):
        if simIM then
            local imgHandle=simIM.readFromVisionSensor(inData.handle)
            local center={inData.resolution[1]/2,inData.resolution[2]/2}
            local radius=(inData.resolution[1]+inData.resolution[2])/8
            simIM.circle(imgHandle,center,radius,{255,255,0},4)
            simIM.writeToVisionSensor(imgHandle,inData.handle)
            simIM.destroy(imgHandle)
        end
    
        -- Or you can directly operate on the image buffer:
        local image=sim.getVisionSensorImg(inData.handle)
        sim.transformImage(image,inData.resolution,4)
        image=sim.transformBuffer(image,sim.buffer_uint8rgb,1,0,sim.buffer_uint8bgr)
        sim.setVisionSensorImg(inData.handle,image)
        
        outData={}
        outData.trigger=true -- whether the sensor should trigger
        -- filters may append packets (in packed form, use sim.packFloatTable to pack) to this table:
        outData.packedPackets={sim.packFloatTable({1,42,57})} 
        return outData
    end



    OMPLPluginAPIreference << Previous Next >> IMPluginAPIreference

    Copyright © All rights reserved | This template is made with by Colorlib