比较提交
合并到: unity-tech-cn:main
unity-tech-cn:/main
unity-tech-cn:/readback_mode
unity-tech-cn:/fix-editor-pause
unity-tech-cn:/docs
unity-tech-cn:/format
unity-tech-cn:/dr-test1
unity-tech-cn:/fix-compile
unity-tech-cn:/fix-links
unity-tech-cn:/fix_startup_exception
unity-tech-cn:/fix-docs
unity-tech-cn:/fix_label_id_report
unity-tech-cn:/update-setup-steps
unity-tech-cn:/labeler_mock
unity-tech-cn:/publish-fix
unity-tech-cn:/result_visualization
unity-tech-cn:/labeler_mock_mb
unity-tech-cn:/labeler_mock_on_camera
unity-tech-cn:/0.1.0-staging
unity-tech-cn:/dr-test2
unity-tech-cn:/release_cleanup
unity-tech-cn:/RC_0.2.0-preview.1
unity-tech-cn:/aisv614_0.2.0
unity-tech-cn:/aisv614_fix
unity-tech-cn:/aisv647_visualizations
unity-tech-cn:/RC-0.2.0-preview.1
unity-tech-cn:/fix_seg_colors
unity-tech-cn:/test
unity-tech-cn:/0.3.0-staging
unity-tech-cn:/aisv565_bbox3d
unity-tech-cn:/aisv749_viz_mem_leak_bug
unity-tech-cn:/aisv754_seg_alpha_bug
unity-tech-cn:/test_request_tracking_completion
unity-tech-cn:/test_new_versions
unity-tech-cn:/usim-randomization
unity-tech-cn:/with_cloud_tests
unity-tech-cn:/0.2.0-staging
unity-tech-cn:/parameter-bahaviours
unity-tech-cn:/upgrade_deps
unity-tech-cn:/0.4.0-staging
unity-tech-cn:/0.5.0-staging-2020.1
unity-tech-cn:/0.5.0-staging
unity-tech-cn:/resint_updates
unity-tech-cn:/tutorial-spelling-fix
unity-tech-cn:/priyesh-urp-dist-render
unity-tech-cn:/multiple-perception-cameras
unity-tech-cn:/pre_release_tests_nov2020
unity-tech-cn:/0.6.0-staging
unity-tech-cn:/fix_performance_tests
unity-tech-cn:/manual_capture
unity-tech-cn:/fod_generator_randomization_changes
unity-tech-cn:/multipleCameras
unity-tech-cn:/Labelbug1101
unity-tech-cn:/replace_index_md
unity-tech-cn:/depth_occlusion
unity-tech-cn:/0.8.0-preview.1_staging
unity-tech-cn:/validation-tool
unity-tech-cn:/addressables-test
unity-tech-cn:/int_tests_on_hdrp
unity-tech-cn:/keypoint_self_occlusion
unity-tech-cn:/seg_opacity
unity-tech-cn:/foreground_object_bounds_normalization
unity-tech-cn:/generic-asset-sources
unity-tech-cn:/local-position-labeler
unity-tech-cn:/pyrception-integration
unity-tech-cn:/fix_sampler_rounding_issue
unity-tech-cn:/h-i
unity-tech-cn:/0.7.0-staging
unity-tech-cn:/Released-0.6.0-preview.1
unity-tech-cn:/moved-from-attribute
unity-tech-cn:/frontpage_shuffle
unity-tech-cn:/coco_export
unity-tech-cn:/public-spec
unity-tech-cn:/fix-3Dexception-typo
unity-tech-cn:/feat-light-randomizer
unity-tech-cn:/schema-0.1.0
unity-tech-cn:/data-cap-update
unity-tech-cn:/0.8.0.preview.4_staging
unity-tech-cn:/faq-page
unity-tech-cn:/orthographic-camera-metadata
unity-tech-cn:/update-docs-0.8.0.preview.4
unity-tech-cn:/priyesh-cloudrendering-test
unity-tech-cn:/Release_0.8.0-preview.4
unity-tech-cn:/tutorial_patch
unity-tech-cn:/add_imageLink_field
unity-tech-cn:/fix_label_config_editor_indexing
unity-tech-cn:/coco_perception_output_hybrid
unity-tech-cn:/fxaa-clarification
unity-tech-cn:/no_editor_coverage
unity-tech-cn:/keypoint_self_occlusion_2020_3
unity-tech-cn:/for_vulkan_mem_test
unity-tech-cn:/solo_support
unity-tech-cn:/fix_multi_cam
unity-tech-cn:/randomizer-serialization-update
unity-tech-cn:/semantic_shader_tests
unity-tech-cn:/revert-sample-scene
unity-tech-cn:/package-analytics
unity-tech-cn:/github-action
unity-tech-cn:/fix-one-extra-frame-before-scenario-starts
unity-tech-cn:/scene_gen
unity-tech-cn:/0.9.0.preview.1_staging
unity-tech-cn:/tag-RC-0.9.0.preview.2
unity-tech-cn:/remove-usim-from-docs
unity-tech-cn:/docs/fix-readme-image-names
unity-tech-cn:/fix-links/jonh
unity-tech-cn:/addressables-test/scheduledcapture
unity-tech-cn:/orthographic-camera-metadata/additions
unity-tech-cn:/github-action/test
拉取从: unity-tech-cn:labeler_mock_on_camera
unity-tech-cn:/main
unity-tech-cn:/readback_mode
unity-tech-cn:/fix-editor-pause
unity-tech-cn:/docs
unity-tech-cn:/format
unity-tech-cn:/dr-test1
unity-tech-cn:/fix-compile
unity-tech-cn:/fix-links
unity-tech-cn:/fix_startup_exception
unity-tech-cn:/fix-docs
unity-tech-cn:/fix_label_id_report
unity-tech-cn:/update-setup-steps
unity-tech-cn:/labeler_mock
unity-tech-cn:/publish-fix
unity-tech-cn:/result_visualization
unity-tech-cn:/labeler_mock_mb
unity-tech-cn:/labeler_mock_on_camera
unity-tech-cn:/0.1.0-staging
unity-tech-cn:/dr-test2
unity-tech-cn:/release_cleanup
unity-tech-cn:/RC_0.2.0-preview.1
unity-tech-cn:/aisv614_0.2.0
unity-tech-cn:/aisv614_fix
unity-tech-cn:/aisv647_visualizations
unity-tech-cn:/RC-0.2.0-preview.1
unity-tech-cn:/fix_seg_colors
unity-tech-cn:/test
unity-tech-cn:/0.3.0-staging
unity-tech-cn:/aisv565_bbox3d
unity-tech-cn:/aisv749_viz_mem_leak_bug
unity-tech-cn:/aisv754_seg_alpha_bug
unity-tech-cn:/test_request_tracking_completion
unity-tech-cn:/test_new_versions
unity-tech-cn:/usim-randomization
unity-tech-cn:/with_cloud_tests
unity-tech-cn:/0.2.0-staging
unity-tech-cn:/parameter-bahaviours
unity-tech-cn:/upgrade_deps
unity-tech-cn:/0.4.0-staging
unity-tech-cn:/0.5.0-staging-2020.1
unity-tech-cn:/0.5.0-staging
unity-tech-cn:/resint_updates
unity-tech-cn:/tutorial-spelling-fix
unity-tech-cn:/priyesh-urp-dist-render
unity-tech-cn:/multiple-perception-cameras
unity-tech-cn:/pre_release_tests_nov2020
unity-tech-cn:/0.6.0-staging
unity-tech-cn:/fix_performance_tests
unity-tech-cn:/manual_capture
unity-tech-cn:/fod_generator_randomization_changes
unity-tech-cn:/multipleCameras
unity-tech-cn:/Labelbug1101
unity-tech-cn:/replace_index_md
unity-tech-cn:/depth_occlusion
unity-tech-cn:/0.8.0-preview.1_staging
unity-tech-cn:/validation-tool
unity-tech-cn:/addressables-test
unity-tech-cn:/int_tests_on_hdrp
unity-tech-cn:/keypoint_self_occlusion
unity-tech-cn:/seg_opacity
unity-tech-cn:/foreground_object_bounds_normalization
unity-tech-cn:/generic-asset-sources
unity-tech-cn:/local-position-labeler
unity-tech-cn:/pyrception-integration
unity-tech-cn:/fix_sampler_rounding_issue
unity-tech-cn:/h-i
unity-tech-cn:/0.7.0-staging
unity-tech-cn:/Released-0.6.0-preview.1
unity-tech-cn:/moved-from-attribute
unity-tech-cn:/frontpage_shuffle
unity-tech-cn:/coco_export
unity-tech-cn:/public-spec
unity-tech-cn:/fix-3Dexception-typo
unity-tech-cn:/feat-light-randomizer
unity-tech-cn:/schema-0.1.0
unity-tech-cn:/data-cap-update
unity-tech-cn:/0.8.0.preview.4_staging
unity-tech-cn:/faq-page
unity-tech-cn:/orthographic-camera-metadata
unity-tech-cn:/update-docs-0.8.0.preview.4
unity-tech-cn:/priyesh-cloudrendering-test
unity-tech-cn:/Release_0.8.0-preview.4
unity-tech-cn:/tutorial_patch
unity-tech-cn:/add_imageLink_field
unity-tech-cn:/fix_label_config_editor_indexing
unity-tech-cn:/coco_perception_output_hybrid
unity-tech-cn:/fxaa-clarification
unity-tech-cn:/no_editor_coverage
unity-tech-cn:/keypoint_self_occlusion_2020_3
unity-tech-cn:/for_vulkan_mem_test
unity-tech-cn:/solo_support
unity-tech-cn:/fix_multi_cam
unity-tech-cn:/randomizer-serialization-update
unity-tech-cn:/semantic_shader_tests
unity-tech-cn:/revert-sample-scene
unity-tech-cn:/package-analytics
unity-tech-cn:/github-action
unity-tech-cn:/fix-one-extra-frame-before-scenario-starts
unity-tech-cn:/scene_gen
unity-tech-cn:/0.9.0.preview.1_staging
unity-tech-cn:/tag-RC-0.9.0.preview.2
unity-tech-cn:/remove-usim-from-docs
unity-tech-cn:/docs/fix-readme-image-names
unity-tech-cn:/fix-links/jonh
unity-tech-cn:/addressables-test/scheduledcapture
unity-tech-cn:/orthographic-camera-metadata/additions
unity-tech-cn:/github-action/test
此合并请求有变更与目标分支冲突。
/TestProjects/PerceptionURP/Packages/manifest.json
/TestProjects/PerceptionURP/ProjectSettings/ProjectVersion.txt
/TestProjects/PerceptionURP/Assets/Scenes/SampleScene.unity
/com.unity.perception/Editor/Unity.Perception.Editor.asmdef
/com.unity.perception/Tests/Runtime/GroundTruthTests/PerceptionCameraIntegrationTests.cs
/com.unity.perception/Tests/Runtime/GroundTruthTests/SegmentationGroundTruthTests.cs
/com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs
/TestProjects/PerceptionURP/Assets/SemanticSegmentationLabelingConfiguration.asset.meta
/com.unity.perception/Runtime/GroundTruth/Labeling/LabelingConfiguration2.cs.meta
/TestProjects/PerceptionURP/Assets/SemanticSegmentationLabelingConfiguration.asset
/TestProjects/PerceptionURP/Assets/SemanticSegmentationLabelingConfiguration.asset.meta
/com.unity.perception/Editor/GroundTruth/PerceptionCameraEditor.cs
/com.unity.perception/Runtime/GroundTruth/Labelers
/com.unity.perception/Editor/GroundTruth/LabelingConfigurationEditor.cs
/com.unity.perception/Runtime/GroundTruth/Labeling/LabelingConfiguration.cs
1 次代码提交
作者 | SHA1 | 备注 | 提交日期 |
---|---|---|---|
Jon Hogins | ab3dae9a | Starting to migrate BoundingBoxLabeler | 4 年前 |
共有 29 个文件被更改,包括 730 次插入 和 65 次删除
-
30TestProjects/PerceptionURP/Assets/Scenes/SampleScene.unity
-
2TestProjects/PerceptionURP/Packages/manifest.json
-
4TestProjects/PerceptionURP/ProjectSettings/ProjectVersion.txt
-
6com.unity.perception/Editor/Unity.Perception.Editor.asmdef
-
18com.unity.perception/Editor/GroundTruth/LabelingConfigurationEditor.cs
-
27com.unity.perception/Runtime/GroundTruth/Labeling/LabelingConfiguration.cs
-
101com.unity.perception/Runtime/GroundTruth/PerceptionCamera.cs
-
4com.unity.perception/Tests/Runtime/GroundTruthTests/PerceptionCameraIntegrationTests.cs
-
4com.unity.perception/Tests/Runtime/GroundTruthTests/SegmentationGroundTruthTests.cs
-
23TestProjects/PerceptionURP/Assets/SemanticSegmentationLabelingConfiguration.asset
-
8TestProjects/PerceptionURP/Assets/SemanticSegmentationLabelingConfiguration.asset.meta
-
3com.unity.perception/Editor/GroundTruth/PerceptionCameraEditor.cs.meta
-
33com.unity.perception/Editor/GroundTruth/LabelingConfigurationImporter.cs
-
3com.unity.perception/Editor/GroundTruth/LabelingConfigurationImporter.cs.meta
-
24com.unity.perception/Editor/GroundTruth/BoundingBoxLabelerEditor.cs
-
3com.unity.perception/Editor/GroundTruth/BoundingBoxLabelerEditor.cs.meta
-
287com.unity.perception/Editor/GroundTruth/PerceptionCameraEditor.cs
-
3com.unity.perception/Runtime/GroundTruth/Labelers.meta
-
108com.unity.perception/Runtime/GroundTruth/Labeling/LabelingConfiguration2.cs
-
3com.unity.perception/Runtime/GroundTruth/Labeling/LabelingConfiguration2.cs.meta
-
11com.unity.perception/Runtime/GroundTruth/Labelers/BoundingBoxLabeler.cs.meta
-
9com.unity.perception/Runtime/GroundTruth/Labelers/InstanceSegmentationLabeler.cs
-
11com.unity.perception/Runtime/GroundTruth/Labelers/InstanceSegmentationLabeler.cs.meta
-
11com.unity.perception/Runtime/GroundTruth/Labelers/RenderedObjectInfoLabeler.cs
-
11com.unity.perception/Runtime/GroundTruth/Labelers/RenderedObjectInfoLabeler.cs.meta
-
10com.unity.perception/Runtime/GroundTruth/Labelers/SemanticSegmentationLabeler.cs
-
11com.unity.perception/Runtime/GroundTruth/Labelers/SemanticSegmentationLabeler.cs.meta
-
27com.unity.perception/Runtime/GroundTruth/Labelers/BoundingBoxLabeler.cs
|
|||
m_EditorVersion: 2019.3.13f1 |
|||
m_EditorVersionWithRevision: 2019.3.13f1 (d4ddf0d95db9) |
|||
m_EditorVersion: 2019.4.0f1 |
|||
m_EditorVersionWithRevision: 2019.4.0f1 (0af376155913) |
|
|||
%YAML 1.1 |
|||
%TAG !u! tag:unity3d.com,2011: |
|||
--- !u!114 &11400000 |
|||
MonoBehaviour: |
|||
m_ObjectHideFlags: 0 |
|||
m_CorrespondingSourceObject: {fileID: 0} |
|||
m_PrefabInstance: {fileID: 0} |
|||
m_PrefabAsset: {fileID: 0} |
|||
m_GameObject: {fileID: 0} |
|||
m_Enabled: 1 |
|||
m_EditorHideFlags: 0 |
|||
m_Script: {fileID: 0} |
|||
m_Name: SemanticSegmentationLabelingConfiguration |
|||
m_EditorClassIdentifier: Unity.Perception.Runtime:UnityEngine.Perception.GroundTruth:SemanticSegmentationLabelConfig |
|||
LabelEntries: |
|||
- label: box |
|||
pixelValue: 10000 |
|||
- label: cube |
|||
pixelValue: 20000 |
|||
- label: crate |
|||
pixelValue: 30000 |
|||
AutoAssignIds: 1 |
|||
StartingLabelId: 1 |
|
|||
fileFormatVersion: 2 |
|||
guid: c140c5aa05dd09e4fadaa26de31b1f39 |
|||
NativeFormatImporter: |
|||
externalObjects: {} |
|||
mainObjectFileID: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: d6936a1fe4b946a8b72f33ac7c4906e4 |
|||
timeCreated: 1589372488 |
|
|||
using System.IO; |
|||
using Newtonsoft.Json.Linq; |
|||
using UnityEditor.Experimental.AssetImporters; |
|||
using UnityEngine; |
|||
using UnityEngine.Perception.GroundTruth; |
|||
|
|||
namespace UnityEditor.Perception.GroundTruth |
|||
{ |
|||
[ScriptedImporter(1, "labelconfig")] |
|||
public class LabelingConfigurationImporter : ScriptedImporter |
|||
{ |
|||
public override void OnImportAsset(AssetImportContext ctx) |
|||
{ |
|||
var text = File.ReadAllText(ctx.assetPath); |
|||
var jObject = JObject.Parse(text); |
|||
var config = ScriptableObject.CreateInstance<LabelingConfiguration>(); |
|||
if (jObject["auto-assign-ids"].HasValues) |
|||
config.AutoAssignIds = jObject["auto-assign-ids"].Value<bool>(); |
|||
|
|||
if (jObject["starting-index"].HasValues) |
|||
{ |
|||
var startingLabelId = (StartingLabelId)jObject["starting-index"].Value<int>(); |
|||
config.StartingLabelId = startingLabelId; |
|||
} |
|||
|
|||
if (jObject["configs"].HasValues) |
|||
{ |
|||
|
|||
} |
|||
ctx.SetMainObject(config); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: b0ecdacff7b34c54b2bad5b04e868356 |
|||
timeCreated: 1589474006 |
|
|||
using UnityEngine; |
|||
using UnityEngine.Perception.GroundTruth; |
|||
|
|||
namespace UnityEditor.Perception.GroundTruth |
|||
{ |
|||
[CustomEditor(typeof(BoundingBoxLabeler))] |
|||
public class BoundingBoxLabelerEditor : Editor |
|||
{ |
|||
public override void OnInspectorGUI() |
|||
{ |
|||
// base.OnInspectorGUI();
|
|||
// return;
|
|||
EditorGUILayout.PropertyField(this.serializedObject.FindProperty(nameof(BoundingBoxLabeler.annotationId))); |
|||
var serializedProperty = this.serializedObject.FindProperty(nameof(BoundingBoxLabeler.labelingConfiguration)); |
|||
|
|||
if (serializedProperty.objectReferenceValue != null) |
|||
{ |
|||
EditorGUILayout.Separator(); |
|||
var editor = Editor.CreateEditor(serializedProperty.objectReferenceValue); |
|||
editor.OnInspectorGUI(); |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: d114d25761d742d4806c0f9e2e498764 |
|||
timeCreated: 1589407154 |
|
|||
using System; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using System.Reflection; |
|||
using UnityEditorInternal; |
|||
using UnityEngine; |
|||
using UnityEngine.Perception.GroundTruth; |
|||
using UnityEngine.Rendering; |
|||
|
|||
namespace UnityEditor.Perception.GroundTruth |
|||
{ |
|||
[CustomEditor(typeof(PerceptionCamera))] |
|||
public class PerceptionCameraEditor : Editor |
|||
{ |
|||
ReorderableList m_LabelersList; |
|||
|
|||
public void OnEnable() |
|||
{ |
|||
m_LabelersList = new ReorderableList(this.serializedObject, this.serializedObject.FindProperty(nameof(PerceptionCamera.labelers)), true, false, true, true); |
|||
m_LabelersList.drawHeaderCallback = (rect) => { |
|||
EditorGUI.LabelField(rect, "Camera Labelers", EditorStyles.largeLabel); |
|||
}; |
|||
m_LabelersList.elementHeightCallback = GetElementHeight; |
|||
m_LabelersList.drawElementCallback = DrawElement; |
|||
m_LabelersList.onAddCallback += OnAdd; |
|||
m_LabelersList.onRemoveCallback += OnRemove; |
|||
} |
|||
|
|||
float GetElementHeight(int index) |
|||
{ |
|||
var serializedProperty = this.serializedObject.FindProperty(nameof(PerceptionCamera.labelers)); |
|||
var element = serializedProperty.GetArrayElementAtIndex(index); |
|||
var editor = GetCameraLabelerDrawer(element, index); |
|||
return editor.GetElementHeight(element); |
|||
} |
|||
|
|||
PerceptionCamera PerceptionCamera => ((PerceptionCamera)this.target); |
|||
|
|||
void DrawElement(Rect rect, int index, bool isactive, bool isfocused) |
|||
{ |
|||
var element = this.serializedObject.FindProperty(nameof(PerceptionCamera.labelers)).GetArrayElementAtIndex(index); |
|||
var editor = GetCameraLabelerDrawer(element, index); |
|||
editor.OnGUI(rect, element); |
|||
} |
|||
|
|||
void OnRemove(ReorderableList list) |
|||
{ |
|||
var labelers = serializedObject.FindProperty(nameof(PerceptionCamera.labelers)); |
|||
labelers.DeleteArrayElementAtIndex(list.index); |
|||
serializedObject.ApplyModifiedProperties(); |
|||
} |
|||
|
|||
void OnAdd(ReorderableList list) |
|||
{ |
|||
Undo.RegisterCompleteObjectUndo(target, "Remove camera labeler"); |
|||
var labelers = this.serializedObject.FindProperty(nameof(PerceptionCamera.labelers)); |
|||
|
|||
var dropdownOptions = TypeCache.GetTypesDerivedFrom<CameraLabeler>(); |
|||
var menu = new GenericMenu(); |
|||
foreach (var option in dropdownOptions) |
|||
{ |
|||
var localOption = option; |
|||
menu.AddItem(new GUIContent(option.Name), |
|||
false, |
|||
() => AddLabeler(labelers, localOption)); |
|||
} |
|||
menu.ShowAsContext(); |
|||
} |
|||
|
|||
void AddLabeler(SerializedProperty labelers, Type labelerType) |
|||
{ |
|||
var insertIndex = labelers.arraySize; |
|||
labelers.InsertArrayElementAtIndex(insertIndex); |
|||
var element = labelers.GetArrayElementAtIndex(insertIndex); |
|||
var labeler = (CameraLabeler) Activator.CreateInstance(labelerType); |
|||
labeler.enabled = true; |
|||
element.managedReferenceValue = labeler; |
|||
serializedObject.ApplyModifiedProperties(); |
|||
} |
|||
|
|||
public override void OnInspectorGUI() |
|||
{ |
|||
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(PerceptionCamera.description))); |
|||
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(PerceptionCamera.period))); |
|||
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(PerceptionCamera.startTime))); |
|||
EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(PerceptionCamera.captureRgbImages))); |
|||
//EditorGUILayout.PropertyField(serializedObject.FindProperty(nameof(PerceptionCamera.labelers)));
|
|||
m_LabelersList.DoLayoutList(); |
|||
} |
|||
|
|||
|
|||
|
|||
Dictionary<SerializedProperty, CameraLabelerDrawer> cameraLabelerDrawers = new Dictionary<SerializedProperty, CameraLabelerDrawer>(); |
|||
CameraLabelerDrawer GetCameraLabelerDrawer(SerializedProperty element, int listIndex) |
|||
{ |
|||
CameraLabelerDrawer drawer; |
|||
|
|||
if (cameraLabelerDrawers.TryGetValue(element, out drawer)) |
|||
return drawer; |
|||
|
|||
var labeler = PerceptionCamera.labelers[listIndex]; |
|||
|
|||
foreach (var drawerType in TypeCache.GetTypesWithAttribute(typeof(CameraLabelerDrawerAttribute))) |
|||
{ |
|||
var attr = drawerType.GetCustomAttributes(typeof(CameraLabelerDrawerAttribute), true)[0] as CameraLabelerDrawerAttribute; |
|||
if (attr.targetLabelerType == labeler.GetType()) |
|||
{ |
|||
drawer = Activator.CreateInstance(drawerType) as CameraLabelerDrawer; |
|||
drawer.CameraLabeler = labeler; |
|||
break; |
|||
} |
|||
if (attr.targetLabelerType.IsAssignableFrom(labeler.GetType())) |
|||
{ |
|||
drawer = Activator.CreateInstance(drawerType) as CameraLabelerDrawer; |
|||
drawer.CameraLabeler = labeler; |
|||
} |
|||
} |
|||
|
|||
cameraLabelerDrawers[element] = drawer; |
|||
|
|||
return drawer; |
|||
} |
|||
} |
|||
|
|||
[AttributeUsage(AttributeTargets.Class)] |
|||
class CameraLabelerDrawerAttribute : Attribute |
|||
{ |
|||
public CameraLabelerDrawerAttribute(Type targetLabelerType) |
|||
{ |
|||
this.targetLabelerType = targetLabelerType; |
|||
} |
|||
public Type targetLabelerType; |
|||
} |
|||
|
|||
[CameraLabelerDrawer(typeof(CameraLabeler))] |
|||
public class CameraLabelerDrawer |
|||
{ |
|||
public CameraLabeler CameraLabeler { get; internal set; } |
|||
|
|||
class Styles |
|||
{ |
|||
public static float defaultLineSpace = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; |
|||
public static float reorderableListHandleIndentWidth = 12; |
|||
public static GUIContent enabled = new GUIContent("Enabled", "Enable or Disable the custom pass"); |
|||
} |
|||
|
|||
bool firstTime = true; |
|||
|
|||
// Serialized Properties
|
|||
SerializedProperty m_Enabled; |
|||
SerializedProperty m_LabelerFoldout; |
|||
List<SerializedProperty> m_CustomPassUserProperties = new List<SerializedProperty>(); |
|||
|
|||
void FetchProperties(SerializedProperty property) |
|||
{ |
|||
m_Enabled = property.FindPropertyRelative(nameof(CameraLabeler.enabled)); |
|||
m_LabelerFoldout = property.FindPropertyRelative(nameof(CameraLabeler.foldout)); |
|||
} |
|||
|
|||
void LoadUserProperties(SerializedProperty customPass) |
|||
{ |
|||
foreach (var field in CameraLabeler.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) |
|||
{ |
|||
var serializeField = field.GetCustomAttribute<SerializeField>(); |
|||
var hideInInspector = field.GetCustomAttribute<HideInInspector>(); |
|||
var nonSerialized = field.GetCustomAttribute<NonSerializedAttribute>(); |
|||
|
|||
if (nonSerialized != null || hideInInspector != null) |
|||
continue; |
|||
|
|||
if (!field.IsPublic && serializeField == null) |
|||
continue; |
|||
|
|||
if (field.Name == nameof(CameraLabeler.enabled) || field.Name == nameof(CameraLabeler.foldout)) |
|||
continue; |
|||
|
|||
var prop = customPass.FindPropertyRelative(field.Name); |
|||
if (prop != null) |
|||
m_CustomPassUserProperties.Add(prop); |
|||
} |
|||
} |
|||
|
|||
void InitInternal(SerializedProperty customPass) |
|||
{ |
|||
FetchProperties(customPass); |
|||
Initialize(customPass); |
|||
LoadUserProperties(customPass); |
|||
firstTime = false; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Use this function to initialize the local SerializedProperty you will use in your pass.
|
|||
/// </summary>
|
|||
/// <param name="customPass">Your custom pass instance represented as a SerializedProperty</param>
|
|||
protected virtual void Initialize(SerializedProperty customPass) {} |
|||
|
|||
internal void OnGUI(Rect rect, SerializedProperty property) |
|||
{ |
|||
rect.height = EditorGUIUtility.singleLineHeight; |
|||
EditorGUI.BeginChangeCheck(); |
|||
|
|||
if (firstTime) |
|||
InitInternal(property); |
|||
|
|||
DoHeaderGUI(ref rect); |
|||
|
|||
if (m_LabelerFoldout.boolValue) |
|||
{ |
|||
EditorGUI.EndChangeCheck(); |
|||
return; |
|||
} |
|||
|
|||
EditorGUI.BeginDisabledGroup(!m_Enabled.boolValue); |
|||
{ |
|||
DoPassGUI(property, rect); |
|||
} |
|||
EditorGUI.EndDisabledGroup(); |
|||
|
|||
if (EditorGUI.EndChangeCheck()) |
|||
property.serializedObject.ApplyModifiedProperties(); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Implement this function to draw your custom GUI.
|
|||
/// </summary>
|
|||
/// <param name="customPass">Your custom pass instance represented as a SerializedProperty</param>
|
|||
/// <param name="rect">space available for you to draw the UI</param>
|
|||
protected virtual void DoPassGUI(SerializedProperty customPass, Rect rect) |
|||
{ |
|||
foreach (var prop in m_CustomPassUserProperties) |
|||
{ |
|||
EditorGUI.PropertyField(rect, prop); |
|||
rect.y += Styles.defaultLineSpace; |
|||
} |
|||
} |
|||
|
|||
void DoHeaderGUI(ref Rect rect) |
|||
{ |
|||
var enabledSize = EditorStyles.boldLabel.CalcSize(Styles.enabled) + new Vector2(Styles.reorderableListHandleIndentWidth, 0); |
|||
var headerRect = new Rect(rect.x + Styles.reorderableListHandleIndentWidth, |
|||
rect.y + EditorGUIUtility.standardVerticalSpacing, |
|||
rect.width - Styles.reorderableListHandleIndentWidth - enabledSize.x, |
|||
EditorGUIUtility.singleLineHeight); |
|||
rect.y += Styles.defaultLineSpace; |
|||
var enabledRect = headerRect; |
|||
enabledRect.x = rect.xMax - enabledSize.x; |
|||
enabledRect.width = enabledSize.x; |
|||
|
|||
m_LabelerFoldout.boolValue = EditorGUI.Foldout(headerRect, m_LabelerFoldout.boolValue, $"{CameraLabeler.GetType().Name}", true, EditorStyles.boldLabel); |
|||
EditorGUIUtility.labelWidth = enabledRect.width - 14; |
|||
m_Enabled.boolValue = EditorGUI.Toggle(enabledRect, Styles.enabled, m_Enabled.boolValue); |
|||
EditorGUIUtility.labelWidth = 0; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Implement this functions if you implement DoPassGUI. The result of this function must match the number of lines displayed in your custom GUI.
|
|||
/// Note that this height can be dynamic.
|
|||
/// </summary>
|
|||
/// <param name="customPass">Your custom pass instance represented as a SerializedProperty</param>
|
|||
/// <returns>The height in pixels of tour custom pass GUI</returns>
|
|||
protected virtual float GetHeight(SerializedProperty customPass) |
|||
{ |
|||
float height = 0; |
|||
|
|||
foreach (var prop in m_CustomPassUserProperties) |
|||
{ |
|||
height += EditorGUI.GetPropertyHeight(prop); |
|||
height += EditorGUIUtility.standardVerticalSpacing; |
|||
} |
|||
|
|||
return height; |
|||
} |
|||
|
|||
internal float GetElementHeight(SerializedProperty property) |
|||
{ |
|||
float height = Styles.defaultLineSpace; |
|||
|
|||
if (firstTime) |
|||
InitInternal(property); |
|||
|
|||
if (m_LabelerFoldout.boolValue) |
|||
return height; |
|||
|
|||
return height + GetHeight(property); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 021a5e99d6664a188c5c78599587a08c |
|||
timeCreated: 1589374593 |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine.Serialization; |
|||
|
|||
namespace UnityEngine.Perception.GroundTruth |
|||
{ |
|||
[Serializable] |
|||
public struct IdLabelEntry : ILabelEntry |
|||
{ |
|||
string ILabelEntry.label => this.label; |
|||
public string label; |
|||
public int id; |
|||
} |
|||
/// <summary>
|
|||
/// A definition for how a <see cref="Labeling"/> should be resolved to a single label and id for ground truth generation.
|
|||
/// </summary>
|
|||
[CreateAssetMenu(fileName = "IdLabelingConfiguration", menuName = "Perception/ID Labeling Configuration", order = 1)] |
|||
public class IdLabelConfig : LabelingConfiguration2<IdLabelEntry> |
|||
{ |
|||
} |
|||
|
|||
[Serializable] |
|||
public struct SemanticSegmentationLabelEntry : ILabelEntry |
|||
{ |
|||
string ILabelEntry.label => this.label; |
|||
public string label; |
|||
public int pixelValue; |
|||
} |
|||
/// <summary>
|
|||
/// A definition for how a <see cref="Labeling"/> should be resolved to a single label and id for ground truth generation.
|
|||
/// </summary>
|
|||
[CreateAssetMenu(fileName = "SemanticSegmentationLabelingConfiguration", menuName = "Perception/Semantic Segmentation Label Config", order = 1)] |
|||
public class SemanticSegmentationLabelConfig : LabelingConfiguration2<SemanticSegmentationLabelEntry> |
|||
{ |
|||
/// <summary>
|
|||
/// Whether the inspector will auto-assign ids based on the id of the first element.
|
|||
/// </summary>
|
|||
public bool AutoAssignIds = true; |
|||
|
|||
/// <summary>
|
|||
/// Whether the inspector will start label ids at zero or one when <see cref="AutoAssignIds"/> is enabled.
|
|||
/// </summary>
|
|||
public StartingLabelId StartingLabelId = StartingLabelId.One; |
|||
} |
|||
/// <summary>
|
|||
/// A definition for how a <see cref="Labeling"/> should be resolved to a single label and id for ground truth generation.
|
|||
/// </summary>
|
|||
[CreateAssetMenu(fileName = "LabelingConfiguration2", menuName = "Perception/Labeling Configuration 2", order = 1)] |
|||
public class LabelingConfiguration2<T> : ScriptableObject where T : ILabelEntry |
|||
{ |
|||
/// <summary>
|
|||
/// A sequence of <see cref="LabelEntry"/> which defines the labels relevant for this configuration and their values.
|
|||
/// </summary>
|
|||
[FormerlySerializedAs("LabelingConfigurations")] |
|||
[SerializeField] |
|||
public List<T> LabelEntries = new List<T>(); |
|||
|
|||
/// <summary>
|
|||
/// Attempts to find the matching index in <see cref="LabelEntries"/> for the given <see cref="Labeling"/>.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// The matching index is the first class name in the given Labeling which matches an entry in <see cref="LabelEntries"/>.
|
|||
/// </remarks>
|
|||
/// <param name="labeling">The <see cref="Labeling"/> to match </param>
|
|||
/// <param name="labelEntry">When this method returns, contains the matching <see cref="LabelEntry"/>, or <code>default</code> if no match was found.</param>
|
|||
/// <returns>Returns true if a match was found. False if not.</returns>
|
|||
public bool TryGetMatchingConfigurationEntry(Labeling labeling, out T labelEntry) |
|||
{ |
|||
return TryGetMatchingConfigurationEntry(labeling, out labelEntry, out int _); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// Attempts to find the matching index in <see cref="LabelEntries"/> for the given <see cref="Labeling"/>.
|
|||
/// </summary>
|
|||
/// <remarks>
|
|||
/// The matching index is the first class name in the given Labeling which matches an entry in <see cref="LabelEntries"/>.
|
|||
/// </remarks>
|
|||
/// <param name="labeling">The <see cref="Labeling"/> to match </param>
|
|||
/// <param name="labelEntry">When this method returns, contains the matching <see cref="LabelEntry"/>, or <code>default</code> if no match was found.</param>
|
|||
/// <param name="labelEntryIndex">When this method returns, contains the index of the matching <see cref="LabelEntry"/>, or <code>-1</code> if no match was found.</param>
|
|||
/// <returns>Returns true if a match was found. False if not.</returns>
|
|||
public bool TryGetMatchingConfigurationEntry(Labeling labeling, out T labelEntry, out int labelEntryIndex) |
|||
{ |
|||
foreach (var labelingClass in labeling.labels) |
|||
{ |
|||
for (var i = 0; i < LabelEntries.Count; i++) |
|||
{ |
|||
var entry = LabelEntries[i]; |
|||
if (string.Equals(entry, labelingClass)) |
|||
{ |
|||
labelEntry = LabelEntries[i]; |
|||
labelEntryIndex = i; |
|||
return true; |
|||
} |
|||
} |
|||
} |
|||
|
|||
labelEntryIndex = -1; |
|||
labelEntry = default; |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
public interface ILabelEntry |
|||
{ |
|||
string label { get; } |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: ef6f93cc88964359a505ccc75835fd5a |
|||
timeCreated: 1589581072 |
|
|||
fileFormatVersion: 2 |
|||
guid: d0127208de324c00a881af84cdd63da3 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
|
|||
namespace UnityEngine.Perception.GroundTruth { |
|||
public class InstanceSegmentationLabeler : CameraLabeler |
|||
{ |
|||
public bool saveImages = false; |
|||
public string annotationId = "E657461D-B950-42E1-8141-BEC9B4810241"; |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 43085b9d882c415b90fb9ebe4d765f26 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
|
|||
namespace UnityEngine.Perception.GroundTruth |
|||
{ |
|||
[Serializable] |
|||
public class RenderedObjectInfoLabeler : CameraLabeler |
|||
{ |
|||
public string annotationId = "F9F22E05-443F-4602-A422-EBE4EA9B55CB"; |
|||
public LabelingConfiguration labelingConfiguration; |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: c2fcc6ce8ec34a44ae0f1679f25b6fb4 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
|
|||
namespace UnityEngine.Perception.GroundTruth { |
|||
[Serializable] |
|||
public class SemanticSegmentationLabeler : CameraLabeler |
|||
{ |
|||
public string annotationId = "12F94D8D-5425-4DEB-9B21-5E53AD957D66"; |
|||
public SemanticSegmentationLabelConfig labelConfig; |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 6c08fb5eff78425db5567cf66f9cb3fc |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Linq; |
|||
|
|||
namespace UnityEngine.Perception.GroundTruth { |
|||
[Serializable] |
|||
public class BoundingBoxLabeler : CameraLabeler |
|||
{ |
|||
public string annotationId = "F9F22E05-443F-4602-A422-EBE4EA9B55CB"; |
|||
public LabelingConfiguration labelingConfiguration; |
|||
AnnotationDefinition m_BoundingBoxAnnotationDefinition; |
|||
|
|||
public override void Setup() |
|||
{ |
|||
var labelingMetricSpec = labelingConfiguration.GetAnnotationSpecification(); |
|||
m_BoundingBoxAnnotationDefinition = SimulationManager.RegisterAnnotationDefinition("bounding box", labelingMetricSpec, "Bounding box for each labeled object visible to the sensor", id: new Guid(annotationId)); |
|||
} |
|||
|
|||
public override void Update() |
|||
{ |
|||
//BoundingBoxAsyncMetric = SensorHandle.ReportAnnotationAsync(m_BoundingBoxAnnotationDefinition);
|
|||
} |
|||
|
|||
public override void OnInstanceSegmentationRead(int frameCount) |
|||
{ |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue