ZEDCameraEditor.cs 88 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544
  1. //======= Copyright (c) Stereolabs Corporation, All rights reserved. ===============
  2. using UnityEngine;
  3. using UnityEditor;
  4. /// <summary>
  5. /// Custom editor used by ZEDManager to extend the default panel shown in the Inspector.
  6. /// Adds the camera status boxes, the button on the bottom to open camera settings, and a button to restart the camera when
  7. /// a settings has changed that requires it.
  8. /// </summary>
  9. [CustomEditor(typeof(ZEDManager)), CanEditMultipleObjects]
  10. public class ZEDCameraEditor : Editor
  11. {
  12. /// <summary>
  13. /// Reference to the ZEDManager instance we're editing.
  14. /// </summary>
  15. ZEDManager manager;
  16. //Store copies of ZEDManager's fields to detect changes later with CheckChange().
  17. //These do not need to be SerializedProperties because they're only used for checking recent changes.
  18. sl.RESOLUTION resolution;
  19. sl.DEPTH_MODE depthmode;
  20. bool usespatialmemory;
  21. //Input Prop
  22. private SerializedProperty cameraIDProperty;
  23. private SerializedProperty inputTypeProperty;
  24. private SerializedProperty depthModeProperty;
  25. private SerializedProperty usbResolutionProperty;
  26. private SerializedProperty usbFPSProperty;
  27. private SerializedProperty svoFileNameProperty;
  28. private SerializedProperty svoLoopProperty;
  29. private SerializedProperty svoRealTimeModeProperty;
  30. private SerializedProperty pauseSVOProperty;
  31. private SerializedProperty currentFrameSVOProperty;
  32. private SerializedProperty maxFrameSVOProperty;
  33. private SerializedProperty streamIPProperty;
  34. private SerializedProperty streamPortProperty;
  35. #if ZED_HDRP
  36. //SRP Lighting Prop
  37. private SerializedProperty srpShaderTypeProperty;
  38. private SerializedProperty selfIlluminationProperty;
  39. private SerializedProperty applyZEDNormalsProperty;
  40. #endif
  41. //Tracking Prop
  42. private SerializedProperty enableTrackingProperty;
  43. private SerializedProperty enableSMProperty;
  44. private SerializedProperty pathSMProperty;
  45. private SerializedProperty estimateIPProperty;
  46. private SerializedProperty trackingIsStaticProperty;
  47. //Rendering Prop
  48. private SerializedProperty depthOcclusionProperty;
  49. private SerializedProperty arpostProcessingPropery;
  50. private SerializedProperty camBrightnessProperty;
  51. //Recording Prop
  52. private SerializedProperty svoOutputFileNameProperty;
  53. private SerializedProperty svoOutputCompressionModeProperty;
  54. private SerializedProperty svoOutputBitrateProperty;
  55. private SerializedProperty svoOutputTargetFPSProperty;
  56. private SerializedProperty svoOutputTranscodeProperty;
  57. //Streaming Prop
  58. private SerializedProperty streamingOutProperty;
  59. private SerializedProperty streamingOutCodecProperty;
  60. private SerializedProperty streamingOutPortProperty;
  61. private SerializedProperty streamingOutBitrateProperty;
  62. private SerializedProperty streamingOutGopSizeProperty;
  63. private SerializedProperty streamingOutAdaptBitrateProperty;
  64. private SerializedProperty streamingOutChunkSizeProperty;
  65. private SerializedProperty streamingOutTargetFPSProperty;
  66. //Spatial mapping prop
  67. private string displayText = "Hide Mesh";
  68. /// <summary>
  69. /// Serialized version of ZEDSpatialMappingManager's range_preset property.
  70. /// </summary>
  71. private SerializedProperty range;
  72. /// <summary>
  73. /// Serialized version of ZEDSpatialMappingManager's resolution_preset property.
  74. /// </summary>
  75. private SerializedProperty mappingResolution;
  76. /// <summary>
  77. /// Serialized version of ZEDSpatialMappingManager's isFilteringEnable property.
  78. /// </summary>
  79. private SerializedProperty isFilteringEnable;
  80. /// <summary>
  81. /// Serialized version of ZEDSpatialMappingManager's filterParameters property.
  82. /// </summary>
  83. private SerializedProperty filterParameters;
  84. /// <summary>
  85. /// Serialized version of ZEDSpatialMappingManager's isTextured property.
  86. /// </summary>
  87. private SerializedProperty saveWhenOver;
  88. /// <summary>
  89. /// Serialized version of ZEDSpatialMappingManager's saveWhenOver property.
  90. /// </summary>
  91. private SerializedProperty isTextured;
  92. /// <summary>
  93. /// Layout option used to draw the '...' button for opening a File Explorer window to find a mesh file.
  94. /// </summary>
  95. private SerializedProperty meshPath;
  96. //Object Detection Prop
  97. private SerializedProperty OD_ImageSyncMode;
  98. private SerializedProperty OD_ObjectTracking;
  99. private SerializedProperty OD_BodyFitting;
  100. private SerializedProperty OD_2DMask;
  101. private SerializedProperty OD_DetectionModel;
  102. private SerializedProperty OD_MaxRange;
  103. private SerializedProperty OD_FilteringMode;
  104. //Object Detection Runtime Prop
  105. private SerializedProperty OD_VehicleDetectionConfidence;
  106. private SerializedProperty OD_PersonDetectionConfidence;
  107. private SerializedProperty SK_PersonDetectionConfidence;
  108. private SerializedProperty OD_BagDetectionConfidence;
  109. private SerializedProperty OD_AnimalDetectionConfidence;
  110. private SerializedProperty OD_ElectronicsDetectionConfidence;
  111. private SerializedProperty OD_FruitVegetableDetectionConfidence;
  112. private SerializedProperty OD_SportDetectionConfidence;
  113. private SerializedProperty OD_PersonFilter;
  114. private SerializedProperty OD_VehicleFilter;
  115. private SerializedProperty OD_BagFilter;
  116. private SerializedProperty OD_AnimalFilter;
  117. private SerializedProperty OD_ElectronicsFilter;
  118. private SerializedProperty OD_FruitVegetableFilter;
  119. private SerializedProperty OD_SportFilter;
  120. /// <summary>
  121. /// Layout option used to draw the '...' button for opening a File Explorer window to find a mesh file.
  122. /// </summary>
  123. private GUILayoutOption[] optionsButtonBrowse = { GUILayout.MaxWidth(30) };
  124. private GUILayoutOption[] optionsButtonStandard = { /*GUILayout.(EditorGUIUtility.labelWidth)*/};
  125. SerializedProperty sensingModeProperty;
  126. SerializedProperty rightDepthProperty;
  127. SerializedProperty maxDepthProperty;
  128. SerializedProperty confidenceThresholdProperty;
  129. SerializedProperty textureConfidenceThresholdProperty;
  130. SerializedProperty enableSelfCalibrationProperty;
  131. SerializedProperty enableIMUFusionProperty;
  132. SerializedProperty opencvCalibFilePath;
  133. // Rendering Prop
  134. private int arlayer;
  135. private SerializedProperty showarrig;
  136. private SerializedProperty fadeinonstart;
  137. private SerializedProperty dontdestroyonload;
  138. private SerializedProperty enableImageEnhancementProperty;
  139. SerializedProperty setIMUPrior;
  140. SerializedProperty allowPassThroughProperty;
  141. SerializedProperty greyskybox;
  142. SerializedProperty showadvanced; //Show advanced settings or not.
  143. SerializedProperty showSpatialMapping; //Show spatial mapping or not.
  144. SerializedProperty showObjectDetection; //show object detection settings or not
  145. SerializedProperty showRecording; //Show recording settings or not.
  146. SerializedProperty showStreamingOut; //Show streaming out settings or not
  147. SerializedProperty showcamcontrol; //Show cam control settings or not.
  148. // Current value for camera controls
  149. SerializedProperty videoSettingsInitModeProperty;
  150. SerializedProperty brightnessProperty;
  151. SerializedProperty contrastProperty;
  152. SerializedProperty hueProperty;
  153. SerializedProperty saturationProperty;
  154. SerializedProperty autoGainExposureProperty;
  155. SerializedProperty exposureProperty;
  156. SerializedProperty gainProperty;
  157. SerializedProperty autoWhiteBalanceProperty;
  158. SerializedProperty whitebalanceProperty;
  159. SerializedProperty sharpnessProperty;
  160. SerializedProperty gammaProperty;
  161. SerializedProperty ledStatus;
  162. //private bool hasLoadedSettings = false;
  163. /// <summary>
  164. /// Whether we've set a manual value to gain and exposure or if they're in auto mode.
  165. /// </summary>
  166. //private bool setManualValue = true;
  167. /// <summary>
  168. /// Whether we've set a manual value to white balance or if it's in auto mode.
  169. /// </summary>
  170. //private bool setManualWhiteBalance = true;
  171. private string[] toolbarStrings = new string[] { "USB", "SVO", "Stream" };
  172. private string pauseText = "Pause";
  173. private string pauseTooltip = " SVO playback or recording."; //Appended to the pause Text to make tooltip text.
  174. private string[] filters = { "Svo files", "svo" }; //Filters used for browsing for an SVO.
  175. private void OnEnable()
  176. {
  177. manager = (ZEDManager)target;
  178. ////////////////////////////////////////////////// FoldOut
  179. showadvanced = serializedObject.FindProperty("advancedPanelOpen");
  180. showSpatialMapping = serializedObject.FindProperty("spatialMappingFoldoutOpen");
  181. showcamcontrol = serializedObject.FindProperty("camControlFoldoutOpen");
  182. showRecording = serializedObject.FindProperty("recordingFoldoutOpen");
  183. showStreamingOut = serializedObject.FindProperty("streamingOutFoldoutOpen");
  184. showObjectDetection = serializedObject.FindProperty("objectDetectionFoldoutOpen");
  185. resolution = manager.resolution;
  186. depthmode = manager.depthMode;
  187. usespatialmemory = manager.enableSpatialMemory;
  188. //Input Serialized Properties
  189. cameraIDProperty = serializedObject.FindProperty("cameraID");
  190. depthModeProperty = serializedObject.FindProperty("depthMode");
  191. inputTypeProperty = serializedObject.FindProperty("inputType");
  192. usbResolutionProperty = serializedObject.FindProperty("resolution");
  193. usbFPSProperty = serializedObject.FindProperty("FPS");
  194. svoFileNameProperty = serializedObject.FindProperty("svoInputFileName");
  195. svoLoopProperty = serializedObject.FindProperty("svoLoopBack");
  196. svoRealTimeModeProperty = serializedObject.FindProperty("svoRealTimeMode");
  197. streamIPProperty = serializedObject.FindProperty("streamInputIP");
  198. streamPortProperty = serializedObject.FindProperty("streamInputPort");
  199. pauseSVOProperty = serializedObject.FindProperty("pauseSVOReading");
  200. currentFrameSVOProperty = serializedObject.FindProperty("currentFrame");
  201. maxFrameSVOProperty = serializedObject.FindProperty("numberFrameMax");
  202. #if ZED_HDRP
  203. //SRP Lighting Serialized Property
  204. srpShaderTypeProperty = serializedObject.FindProperty("srpShaderType");
  205. selfIlluminationProperty = serializedObject.FindProperty("selfIllumination");
  206. applyZEDNormalsProperty = serializedObject.FindProperty("applyZEDNormals");
  207. #endif
  208. //Tracking Serialized Properties
  209. enableTrackingProperty = serializedObject.FindProperty("enableTracking");
  210. enableSMProperty = serializedObject.FindProperty("enableSpatialMemory");
  211. pathSMProperty = serializedObject.FindProperty("pathSpatialMemory");
  212. estimateIPProperty = serializedObject.FindProperty("estimateInitialPosition");
  213. trackingIsStaticProperty = serializedObject.FindProperty("trackingIsStatic");
  214. ///Rendering Serialized Properties
  215. depthOcclusionProperty = serializedObject.FindProperty("depthOcclusion");
  216. arpostProcessingPropery = serializedObject.FindProperty("postProcessing");
  217. camBrightnessProperty = serializedObject.FindProperty("m_cameraBrightness");
  218. ///Spatial Mapping Serialized Properties
  219. range = serializedObject.FindProperty("mappingRangePreset");
  220. mappingResolution = serializedObject.FindProperty("mappingResolutionPreset");
  221. isFilteringEnable = serializedObject.FindProperty("isMappingFilteringEnable");
  222. filterParameters = serializedObject.FindProperty("meshFilterParameters");
  223. isTextured = serializedObject.FindProperty("isMappingTextured");
  224. saveWhenOver = serializedObject.FindProperty("saveMeshWhenOver");
  225. meshPath = serializedObject.FindProperty("meshPath");
  226. ///Object Detection Serialized Properties
  227. OD_ImageSyncMode = serializedObject.FindProperty("objectDetectionImageSyncMode");
  228. OD_ObjectTracking = serializedObject.FindProperty("objectDetectionTracking");
  229. OD_BodyFitting = serializedObject.FindProperty("objectDetectionBodyFitting");
  230. OD_2DMask = serializedObject.FindProperty("objectDetection2DMask");
  231. OD_DetectionModel = serializedObject.FindProperty("objectDetectionModel");
  232. OD_MaxRange = serializedObject.FindProperty("objectDetectionMaxRange");
  233. OD_FilteringMode = serializedObject.FindProperty("objectDetectionFilteringMode");
  234. OD_PersonDetectionConfidence = serializedObject.FindProperty("OD_personDetectionConfidenceThreshold");
  235. SK_PersonDetectionConfidence = serializedObject.FindProperty("SK_personDetectionConfidenceThreshold");
  236. OD_VehicleDetectionConfidence = serializedObject.FindProperty("vehicleDetectionConfidenceThreshold");
  237. OD_BagDetectionConfidence = serializedObject.FindProperty("bagDetectionConfidenceThreshold");
  238. OD_AnimalDetectionConfidence = serializedObject.FindProperty("animalDetectionConfidenceThreshold");
  239. OD_ElectronicsDetectionConfidence = serializedObject.FindProperty("electronicsDetectionConfidenceThreshold");
  240. OD_FruitVegetableDetectionConfidence = serializedObject.FindProperty("fruitVegetableDetectionConfidenceThreshold");
  241. OD_SportDetectionConfidence = serializedObject.FindProperty("sportDetectionConfidenceThreshold");
  242. OD_PersonFilter = serializedObject.FindProperty("objectClassPersonFilter");
  243. OD_VehicleFilter = serializedObject.FindProperty("objectClassVehicleFilter");
  244. OD_BagFilter = serializedObject.FindProperty("objectClassBagFilter");
  245. OD_AnimalFilter = serializedObject.FindProperty("objectClassAnimalFilter");
  246. OD_ElectronicsFilter = serializedObject.FindProperty("objectClassElectronicsFilter");
  247. OD_FruitVegetableFilter = serializedObject.FindProperty("objectClassFruitVegetableFilter");
  248. OD_SportFilter = serializedObject.FindProperty("objectClassSportFilter");
  249. //Recording Serialized Properties
  250. svoOutputFileNameProperty = serializedObject.FindProperty("svoOutputFileName");
  251. svoOutputCompressionModeProperty = serializedObject.FindProperty("svoOutputCompressionMode");
  252. svoOutputBitrateProperty = serializedObject.FindProperty("svoOutputBitrate");
  253. svoOutputTargetFPSProperty = serializedObject.FindProperty("svoOutputTargetFPS");
  254. svoOutputTranscodeProperty = serializedObject.FindProperty("svoOutputTranscodeStreaming");
  255. streamingOutProperty = serializedObject.FindProperty("enableStreaming");
  256. streamingOutCodecProperty = serializedObject.FindProperty("streamingCodec");
  257. streamingOutPortProperty = serializedObject.FindProperty("streamingPort");
  258. streamingOutBitrateProperty = serializedObject.FindProperty("bitrate");
  259. streamingOutGopSizeProperty = serializedObject.FindProperty("gopSize");
  260. streamingOutAdaptBitrateProperty = serializedObject.FindProperty("adaptativeBitrate");
  261. streamingOutChunkSizeProperty = serializedObject.FindProperty("chunkSize");
  262. streamingOutTargetFPSProperty = serializedObject.FindProperty("streamingTargetFramerate");
  263. ///Advanced Settings Serialized Properties
  264. arlayer = ZEDLayers.arlayer;
  265. showarrig = serializedObject.FindProperty("showarrig");
  266. fadeinonstart = serializedObject.FindProperty("fadeInOnStart");
  267. greyskybox = serializedObject.FindProperty("greySkybox");
  268. dontdestroyonload = serializedObject.FindProperty("dontDestroyOnLoad");
  269. showarrig = serializedObject.FindProperty("showarrig");
  270. sensingModeProperty = serializedObject.FindProperty("sensingMode");
  271. rightDepthProperty = serializedObject.FindProperty("enableRightDepthMeasure");
  272. maxDepthProperty = serializedObject.FindProperty("m_maxDepthRange");
  273. confidenceThresholdProperty = serializedObject.FindProperty("m_confidenceThreshold");
  274. textureConfidenceThresholdProperty = serializedObject.FindProperty("m_textureConfidenceThreshold");
  275. enableSelfCalibrationProperty = serializedObject.FindProperty("enableSelfCalibration");
  276. enableIMUFusionProperty = serializedObject.FindProperty("enableIMUFusion");
  277. allowPassThroughProperty = serializedObject.FindProperty("allowARPassThrough");
  278. setIMUPrior = serializedObject.FindProperty("setIMUPriorInAR");
  279. enableImageEnhancementProperty = serializedObject.FindProperty("enableImageEnhancement");
  280. opencvCalibFilePath = serializedObject.FindProperty("opencvCalibFile");
  281. //Video Settings Serialized Properties
  282. videoSettingsInitModeProperty = serializedObject.FindProperty("videoSettingsInitMode");
  283. brightnessProperty = serializedObject.FindProperty("videoBrightness"); ;
  284. contrastProperty = serializedObject.FindProperty("videoContrast"); ;
  285. hueProperty = serializedObject.FindProperty("videoHue"); ;
  286. saturationProperty = serializedObject.FindProperty("videoSaturation"); ;
  287. autoGainExposureProperty = serializedObject.FindProperty("videoAutoGainExposure"); ;
  288. gainProperty = serializedObject.FindProperty("videoGain"); ;
  289. exposureProperty = serializedObject.FindProperty("videoExposure"); ;
  290. autoWhiteBalanceProperty = serializedObject.FindProperty("videoAutoWhiteBalance"); ;
  291. whitebalanceProperty = serializedObject.FindProperty("videoWhiteBalance"); ;
  292. sharpnessProperty = serializedObject.FindProperty("videoSharpness");
  293. gammaProperty = serializedObject.FindProperty("videoGamma");
  294. ledStatus = serializedObject.FindProperty("videoLEDStatus"); ;
  295. }
  296. public override void OnInspectorGUI()
  297. {
  298. GUIStyle boldfoldout = new GUIStyle(EditorStyles.foldout);
  299. boldfoldout.fontStyle = FontStyle.Bold;
  300. //DrawDefaultInspector(); //Draws what you'd normally see in the inspector in absence of a custom inspector.
  301. EditorGUIUtility.labelWidth = EditorGUIUtility.currentViewWidth * 0.4f;
  302. ///////////////////////////////////////////////////////////////
  303. /// Inputlayout /////////////////////////////////
  304. /////////////////////////////////////////////////////////////
  305. GUILayout.Space(10);
  306. EditorGUILayout.LabelField("Input", EditorStyles.boldLabel);
  307. GUILayout.Space(5);
  308. EditorGUI.indentLevel++;
  309. GUIContent cameraIDLabel = new GUIContent("Camera ID", "Which ZED camera to connect to. Used when multiple ZED cameras are connected to this device.");
  310. cameraIDProperty.enumValueIndex = (int)(sl.ZED_CAMERA_ID)EditorGUILayout.EnumPopup(cameraIDLabel, (sl.ZED_CAMERA_ID)cameraIDProperty.enumValueIndex);
  311. GUIContent cameraDepthModeLabel = new GUIContent("Depth Mode", "Camera depth mode. Higher values increase quality at the cost of performance.");
  312. depthModeProperty.enumValueIndex = (int)(sl.DEPTH_MODE)EditorGUILayout.EnumPopup(cameraDepthModeLabel, (sl.DEPTH_MODE)depthModeProperty.enumValueIndex);
  313. GUILayout.Space(15);
  314. EditorGUILayout.BeginHorizontal();
  315. GUIContent inputTypeLabel = new GUIContent("Input Type", "Where the ZED video feed comes from.\r\n\n" +
  316. "- USB: A live ZED camera connected to this device.\r\n\n- SVO: A video file recorded from a ZED previously.\r\n\n" +
  317. "- Stream: A live ZED camera connected to a device elsewhere on the network.");
  318. EditorGUILayout.LabelField(inputTypeLabel, GUILayout.Width(EditorGUIUtility.labelWidth));
  319. GUI.enabled = !Application.isPlaying;
  320. inputTypeProperty.intValue = GUILayout.Toolbar(inputTypeProperty.intValue, toolbarStrings, GUILayout.ExpandWidth(true));
  321. GUI.enabled = true;
  322. EditorGUILayout.EndHorizontal();
  323. GUILayout.Space(5);
  324. switch (inputTypeProperty.intValue)
  325. {
  326. case 0:
  327. GUIContent cameraResolutionLabel = new GUIContent("Resolution", "Camera resolution.");
  328. //GUI.enabled = !Application.isPlaying;
  329. usbResolutionProperty.enumValueIndex = (int)(sl.RESOLUTION)EditorGUILayout.EnumPopup(cameraResolutionLabel, (sl.RESOLUTION)usbResolutionProperty.enumValueIndex);
  330. //GUI.enabled = true;
  331. GUIContent cameraFPSLabel = new GUIContent("FPS", "Desired camera FPS. Maximum FPS depends on your resolution setting:\r\n\n" +
  332. "- HD2k: 15FPS\r\n\n- HD1080: 30FPS\r\n\n- HD720p: 60FPS\r\n\n- VGA: 100FPS");
  333. GUI.enabled = !Application.isPlaying;
  334. usbFPSProperty.intValue = EditorGUILayout.IntField(cameraFPSLabel, usbFPSProperty.intValue);
  335. GUI.enabled = true;
  336. serializedObject.ApplyModifiedProperties();
  337. //Check if we need to restart the camera, and create a button for the user to do so.
  338. if (Application.isPlaying && manager.IsZEDReady && CheckChange())
  339. {
  340. GUILayout.Space(10);
  341. GUIStyle orangetext = new GUIStyle(EditorStyles.label);
  342. orangetext.normal.textColor = Color.red;
  343. orangetext.wordWrap = true;
  344. string labeltext = "Settings have changed that require restarting the camera to apply.";
  345. Rect labelrect = GUILayoutUtility.GetRect(new GUIContent(labeltext, ""), orangetext);
  346. EditorGUI.LabelField(labelrect, labeltext, orangetext);
  347. if (GUILayout.Button("Restart Camera"))
  348. {
  349. manager.Reset(); //Reset the ZED.
  350. //Reset the fields now that they're synced.
  351. resolution = manager.resolution;
  352. depthmode = manager.depthMode;
  353. }
  354. }
  355. break;
  356. case 1:
  357. EditorGUILayout.BeginHorizontal();
  358. GUIContent svoFileNameLabel = new GUIContent("SVO File", "SVO file name");
  359. GUI.enabled = !Application.isPlaying;
  360. svoFileNameProperty.stringValue = EditorGUILayout.TextField(svoFileNameLabel, svoFileNameProperty.stringValue);
  361. GUIContent loadSVOlabel = new GUIContent("...", "Browse for existing SVO file.");
  362. if (GUILayout.Button(loadSVOlabel, optionsButtonBrowse))
  363. {
  364. svoFileNameProperty.stringValue = EditorUtility.OpenFilePanelWithFilters("Load SVO", "", filters);
  365. }
  366. GUI.enabled = true;
  367. EditorGUILayout.EndHorizontal();
  368. GUIContent svoLoopLabel = new GUIContent("Loop SVO", "Loop SVO when it reaches the end.");
  369. svoLoopProperty.boolValue = EditorGUILayout.Toggle(svoLoopLabel, svoLoopProperty.boolValue);
  370. GUIContent svoRealTimeModelabel = new GUIContent("Real-Time Mode", "When enabled, the time between frames comes from the actual timestamps of each frame. Otherwise, " +
  371. "each frame is read based on the maximum FPS of the recorded resolution (ex. 30FPS for HD1080). Real-Time mode makes playback speed more true, but dropped frames result in pauses.");
  372. svoRealTimeModeProperty.boolValue = EditorGUILayout.Toggle(svoRealTimeModelabel, svoRealTimeModeProperty.boolValue);
  373. EditorGUI.BeginChangeCheck();
  374. GUI.enabled = (manager.NumberFrameMax > 0);
  375. GUIContent sliderlabel = new GUIContent("Frame ", "SVO playback position");
  376. currentFrameSVOProperty.intValue = EditorGUILayout.IntSlider(sliderlabel, currentFrameSVOProperty.intValue, 0, maxFrameSVOProperty.intValue);
  377. if (EditorGUI.EndChangeCheck())
  378. {
  379. if (manager.zedCamera != null)
  380. {
  381. //If the slider of frame from the SVO has moved, manually grab the frame and update the textures.
  382. manager.zedCamera.SetSVOPosition(currentFrameSVOProperty.intValue);
  383. if (pauseSVOProperty.boolValue)
  384. {
  385. manager.NeedNewFrameGrab = true;
  386. }
  387. }
  388. }
  389. GUI.enabled = false;
  390. if (manager.zedCamera != null)
  391. GUI.enabled = manager.zedCamera.IsCameraReady;
  392. EditorGUILayout.BeginHorizontal();
  393. GUILayout.Space(EditorGUIUtility.labelWidth);
  394. pauseText = pauseSVOProperty.boolValue ? "Resume" : "Pause";
  395. GUIContent pauselabel = new GUIContent(pauseText, pauseText + pauseTooltip);
  396. if (GUILayout.Button(pauselabel))
  397. {
  398. pauseSVOProperty.boolValue = !pauseSVOProperty.boolValue;
  399. }
  400. EditorGUILayout.EndHorizontal();
  401. GUI.enabled = true;
  402. serializedObject.ApplyModifiedProperties();
  403. break;
  404. case 2:
  405. GUIContent streamIPLabel = new GUIContent("IP", "IP of the host device with the ZED attached.");
  406. GUI.enabled = !Application.isPlaying;
  407. streamIPProperty.stringValue = EditorGUILayout.TextField(streamIPLabel, streamIPProperty.stringValue);
  408. GUI.enabled = true;
  409. GUIContent streamPortLabel = new GUIContent("Port", "Port where the ZED stream is sent to.");
  410. GUI.enabled = !Application.isPlaying;
  411. streamPortProperty.intValue = EditorGUILayout.IntField(streamPortLabel, streamPortProperty.intValue);
  412. GUI.enabled = true;
  413. serializedObject.ApplyModifiedProperties();
  414. break;
  415. }
  416. EditorGUI.indentLevel--;
  417. #if ZED_HDRP
  418. ///////////////////////////////////////////////////////////////
  419. /// HDRP Lighting layout /////////////////////////////////
  420. /////////////////////////////////////////////////////////////
  421. GUILayout.Space(10);
  422. EditorGUILayout.LabelField("SRP Lighting", EditorStyles.boldLabel);
  423. GUILayout.Space(5);
  424. EditorGUI.indentLevel++;
  425. GUIContent shaderTypeLabel = new GUIContent("Lighting Type", "Defines the type of shader (lit or unlit) that's applied to the canvas object(s) used to display the ZED image. " +
  426. "Lit takes into account scene lighting - it is the most realistic but harder to configure. Unlit makes the ZED image evenly lit, but lacks lighting/shadow effects.");
  427. string[] shaderoptions = new string[5] { "Lit", "Unlit", "Lit Greenscreen", "Unlit Greenscreen", "Don't Change"};
  428. GUI.enabled = !Application.isPlaying;
  429. srpShaderTypeProperty.enumValueIndex = EditorGUILayout.Popup(shaderTypeLabel, srpShaderTypeProperty.enumValueIndex, shaderoptions);
  430. GUI.enabled = true;
  431. if (srpShaderTypeProperty.enumValueIndex == 2 || srpShaderTypeProperty.enumValueIndex == 3)
  432. {
  433. GUIStyle greenscreennotestyle = new GUIStyle();
  434. greenscreennotestyle.normal.textColor = new Color(.7f, .7f, .7f);
  435. greenscreennotestyle.wordWrap = true;
  436. greenscreennotestyle.fontSize = 10;
  437. greenscreennotestyle.fixedWidth = 0;
  438. greenscreennotestyle.stretchWidth = false;
  439. greenscreennotestyle.alignment = TextAnchor.MiddleLeft;
  440. greenscreennotestyle.fontStyle = FontStyle.Italic;
  441. GUILayout.Space(2);
  442. EditorGUI.indentLevel++;
  443. string greenscreennote = "Requires GreenScreenManager component on the ZED rig's Camera objects.";
  444. Rect gsrect = GUILayoutUtility.GetRect(new GUIContent(greenscreennote, ""), greenscreennotestyle);
  445. EditorGUI.LabelField(gsrect, greenscreennote, greenscreennotestyle);
  446. GUILayout.Space(8);
  447. EditorGUI.indentLevel--;
  448. }
  449. if (srpShaderTypeProperty.enumValueIndex == 0 || srpShaderTypeProperty.enumValueIndex == 2)
  450. {
  451. GUIContent selfIlluminationLabel = new GUIContent("Self-Illumination", "How much the ZED image should light itself via emission. " +
  452. "Setting to zero is most realistic, but requires you to emulate the real-world lighting conditions within Unity. Higher settings cause the image " +
  453. "to be uniformly lit, but light and shadow effects are less visible.");
  454. selfIlluminationProperty.floatValue = EditorGUILayout.Slider(selfIlluminationLabel, selfIlluminationProperty.floatValue, 0, 1);
  455. GUIContent applyZEDNormalsLabel = new GUIContent("ZED Normals", "Apply normals map from the ZED SDK. Causes lighting to be calculated based "
  456. + "on the real-world angle of the geometry, instead of treating the ZED image like a plane. However, the normals map is imperfect and can lead to noise.");
  457. applyZEDNormalsProperty.boolValue = EditorGUILayout.Toggle(applyZEDNormalsLabel, applyZEDNormalsProperty.boolValue);
  458. }
  459. EditorGUI.indentLevel--;
  460. #endif
  461. ///////////////////////////////////////////////////////////////
  462. /// Motion Tracking layout /////////////////////////////////
  463. /////////////////////////////////////////////////////////////
  464. GUILayout.Space(10);
  465. EditorGUILayout.LabelField("Motion Tracking", EditorStyles.boldLabel);
  466. GUILayout.Space(5);
  467. EditorGUI.indentLevel++;
  468. GUIContent enableTrackingLabel = new GUIContent("Enable Tracking", "If enabled, the ZED will move/rotate itself using its own inside-out tracking. " +
  469. "If false, the camera tracking will move with the VR HMD if connected and available.");
  470. enableTrackingProperty.boolValue = EditorGUILayout.Toggle(enableTrackingLabel, enableTrackingProperty.boolValue);
  471. GUIContent enableSMPropertyLabel = new GUIContent("Enable Spatial Memory", "Enables the spatial memory. Will detect and correct tracking drift by remembering features and anchors in the environment, "
  472. + "but may cause visible jumps when it happens");
  473. enableSMProperty.boolValue = EditorGUILayout.Toggle(enableSMPropertyLabel, enableSMProperty.boolValue);
  474. GUIContent pathSMlabel = new GUIContent("Path Spatial Memory", "If using Spatial Memory, you can specify a path to an existing .area file to start with some memory already loaded. " +
  475. ".area files are created by scanning a scene with ZEDSpatialMappingManager and saving the scan.");
  476. pathSMProperty.stringValue = EditorGUILayout.TextField(pathSMlabel, pathSMProperty.stringValue);
  477. GUIContent estimateIPPropertyLabel = new GUIContent("Estimate Initial Position", "Estimate initial position by detecting the floor. Leave it false if using VR Headset");
  478. estimateIPProperty.boolValue = EditorGUILayout.Toggle(estimateIPPropertyLabel, estimateIPProperty.boolValue);
  479. GUIContent trackingIsStaticPropertyLabel = new GUIContent("Tracking Is Static", "If true, tracking is enabled but doesn't move after initializing. " +
  480. "Can be useful for stationary cameras where you still need tracking enabled, such as in Object Detection.");
  481. trackingIsStaticProperty.boolValue = EditorGUILayout.Toggle(trackingIsStaticPropertyLabel, trackingIsStaticProperty.boolValue);
  482. EditorGUI.indentLevel--;
  483. ///////////////////////////////////////////////////////////////
  484. /// Rendering layout /////////////////////////////////
  485. /////////////////////////////////////////////////////////////
  486. GUILayout.Space(10);
  487. EditorGUILayout.LabelField("Rendering", EditorStyles.boldLabel);
  488. GUILayout.Space(5);
  489. EditorGUI.indentLevel++;
  490. GUIContent depthOcclusionPropertyLabel = new GUIContent("Depth Occlusion", "When enabled, the real world can occlude (cover up) virtual objects that are behind it. " +
  491. "Otherwise, virtual objects will appear in front.");
  492. depthOcclusionProperty.boolValue = EditorGUILayout.Toggle(depthOcclusionPropertyLabel, depthOcclusionProperty.boolValue);
  493. GUIContent arpostProcessingProperyLabel = new GUIContent("AR Post-Processing", "Enables post-processing effects on virtual objects that blends them in with the real world.");
  494. arpostProcessingPropery.boolValue = EditorGUILayout.Toggle(arpostProcessingProperyLabel, arpostProcessingPropery.boolValue);
  495. GUIContent camBrightnessPropertyLabel = new GUIContent("Camera Brightness", "Brightness of the final real-world image. Default is 100. Lower to darken the environment in a realistic-looking way. " +
  496. "This is a rendering setting that doesn't affect the raw input from the camera.");
  497. camBrightnessProperty.intValue = EditorGUILayout.IntSlider(camBrightnessPropertyLabel, camBrightnessProperty.intValue, 0, 100);
  498. EditorGUI.indentLevel--;
  499. ///////////////////////////////////////////////////////////////
  500. /// Spatial Mapping layout /////////////////////////////////
  501. /////////////////////////////////////////////////////////////
  502. GUILayout.Space(10);
  503. showSpatialMapping.boolValue = EditorGUILayout.Foldout(showSpatialMapping.boolValue, "Spatial Mapping", boldfoldout);
  504. if (showSpatialMapping.boolValue)
  505. {
  506. EditorGUI.indentLevel++;
  507. bool cameraIsReady = false;
  508. if (manager)
  509. cameraIsReady = manager.zedCamera != null ? manager.zedCamera.IsCameraReady : false;
  510. displayText = manager.IsSpatialMappingDisplay ? "Hide Mesh" : "Display Mesh";
  511. EditorGUILayout.BeginHorizontal();
  512. GUILayout.Space(5);
  513. EditorGUILayout.EndHorizontal();
  514. GUIContent resolutionlabel = new GUIContent("Resolution", "Resolution setting for the scan. " +
  515. "A higher resolution creates more submeshes and uses more memory, but is more accurate.");
  516. ZEDSpatialMapping.RESOLUTION newResolution = (ZEDSpatialMapping.RESOLUTION)EditorGUILayout.EnumPopup(resolutionlabel, manager.mappingResolutionPreset);
  517. if (newResolution != manager.mappingResolutionPreset)
  518. {
  519. mappingResolution.enumValueIndex = (int)newResolution;
  520. serializedObject.ApplyModifiedProperties();
  521. }
  522. GUIContent rangelabel = new GUIContent("Range", "Maximum distance geometry can be from the camera to be scanned. " +
  523. "Geometry scanned from farther away will be less accurate.");
  524. ZEDSpatialMapping.RANGE newRange = (ZEDSpatialMapping.RANGE)EditorGUILayout.EnumPopup(rangelabel, manager.mappingRangePreset);
  525. if (newRange != manager.mappingRangePreset)
  526. {
  527. range.enumValueIndex = (int)newRange;
  528. serializedObject.ApplyModifiedProperties();
  529. }
  530. EditorGUILayout.BeginHorizontal();
  531. GUIContent filteringlabel = new GUIContent("Mesh Filtering", "Whether mesh filtering is needed.");
  532. filterParameters.enumValueIndex = (int)(sl.FILTER)EditorGUILayout.EnumPopup(filteringlabel, (sl.FILTER)filterParameters.enumValueIndex);
  533. isFilteringEnable.boolValue = true;
  534. EditorGUILayout.EndHorizontal();
  535. GUI.enabled = !manager.IsMappingRunning; //Don't allow changing the texturing setting while the scan is running.
  536. GUIContent texturedlabel = new GUIContent("Texturing", "Whether surface textures will be scanned and applied. " +
  537. "Note that texturing will add further delay to the post-scan finalizing period.");
  538. isTextured.boolValue = EditorGUILayout.Toggle(texturedlabel, isTextured.boolValue);
  539. GUI.enabled = cameraIsReady; //Gray out below elements if the ZED hasn't been initialized as you can't yet start a scan.
  540. EditorGUILayout.BeginHorizontal();
  541. GUILayout.Space(EditorGUIUtility.labelWidth);
  542. if (!manager.IsMappingRunning)
  543. {
  544. GUIContent startmappinglabel = new GUIContent("Start Spatial Mapping", "Begin the spatial mapping process.");
  545. if (GUILayout.Button(startmappinglabel))
  546. {
  547. if (!manager.IsSpatialMappingDisplay)
  548. {
  549. manager.SwitchDisplayMeshState(true);
  550. }
  551. manager.StartSpatialMapping();
  552. }
  553. }
  554. else
  555. {
  556. if (manager.IsMappingRunning && !manager.IsMappingUpdateThreadRunning || manager.IsMappingRunning && manager.IsMappingTexturingRunning)
  557. {
  558. GUILayout.FlexibleSpace();
  559. GUIContent finishinglabel = new GUIContent("Spatial mapping is finishing", "Please wait - the mesh is being processed.");
  560. GUILayout.Label(finishinglabel);
  561. Repaint();
  562. GUILayout.FlexibleSpace();
  563. }
  564. else
  565. {
  566. GUIContent stopmappinglabel = new GUIContent("Stop Spatial Mapping", "Ends spatial mapping and begins processing the final mesh.");
  567. if (GUILayout.Button(stopmappinglabel))
  568. {
  569. manager.StopSpatialMapping();
  570. }
  571. }
  572. }
  573. EditorGUILayout.EndHorizontal();
  574. EditorGUILayout.BeginHorizontal();
  575. GUI.enabled = cameraIsReady;
  576. string displaytooltip = manager.IsSpatialMappingDisplay ? "Hide the mesh from view." : "Display the hidden mesh.";
  577. GUILayout.Space(EditorGUIUtility.labelWidth);
  578. GUIContent displaylabel = new GUIContent(displayText, displaytooltip);
  579. if (GUILayout.Button(displayText))
  580. {
  581. manager.SwitchDisplayMeshState(!manager.IsSpatialMappingDisplay);
  582. }
  583. EditorGUILayout.EndHorizontal();
  584. EditorGUILayout.BeginHorizontal();
  585. GUIContent clearMesheslabel = new GUIContent("Clear All Meshes", "Clear all meshes created with the ZED");
  586. GUILayout.Space(EditorGUIUtility.labelWidth);
  587. if (GUILayout.Button(clearMesheslabel))
  588. {
  589. manager.ClearAllMeshes();
  590. }
  591. EditorGUILayout.EndHorizontal();
  592. GUI.enabled = true;
  593. GUILayout.Space(5);
  594. EditorGUILayout.LabelField("Storage", EditorStyles.boldLabel);
  595. GUIContent savelabel = new GUIContent("Save Mesh (when finished)", "Whether to save the mesh and .area file when finished scanning.");
  596. saveWhenOver.boolValue = EditorGUILayout.Toggle(savelabel, saveWhenOver.boolValue);
  597. EditorGUILayout.BeginHorizontal();
  598. GUIContent pathlabel = new GUIContent("Mesh Path", "Path where the mesh is saved/loaded from. Valid file types are .obj, .ply and .bin.");
  599. meshPath.stringValue = EditorGUILayout.TextField(pathlabel, meshPath.stringValue);
  600. GUIContent findfilelabel = new GUIContent("...", "Browse for an existing .obj, .ply or .bin file.");
  601. if (GUILayout.Button(findfilelabel, optionsButtonBrowse))
  602. {
  603. meshPath.stringValue = EditorUtility.OpenFilePanel("Mesh file", "", "ply,obj,bin");
  604. serializedObject.ApplyModifiedProperties();
  605. }
  606. EditorGUILayout.EndHorizontal();
  607. EditorGUILayout.BeginHorizontal();
  608. GUILayout.FlexibleSpace();
  609. GUI.enabled = System.IO.File.Exists(meshPath.stringValue) && cameraIsReady;
  610. GUIContent loadlabel = new GUIContent("Load", "Load an existing mesh and .area file into the scene.");
  611. if (GUILayout.Button(loadlabel))
  612. {
  613. manager.LoadMesh(meshPath.stringValue);
  614. }
  615. EditorGUILayout.EndHorizontal();
  616. GUI.enabled = true;
  617. EditorGUI.indentLevel--;
  618. }
  619. serializedObject.ApplyModifiedProperties();
  620. ///////////////////////////////////////////////////////////////
  621. /// Object Detection layout /////////////////////////////////
  622. /////////////////////////////////////////////////////////////
  623. GUILayout.Space(10);
  624. showObjectDetection.boolValue = EditorGUILayout.Foldout(showObjectDetection.boolValue, "Object Detection / Body Tracking", boldfoldout);
  625. if (showObjectDetection.boolValue)
  626. {
  627. bool cameraIsReady = false;
  628. if (manager)
  629. cameraIsReady = manager.zedCamera != null ? manager.zedCamera.IsCameraReady : false;
  630. GUILayout.Space(10);
  631. EditorGUILayout.LabelField("Detection Mode", EditorStyles.boldLabel);
  632. GUILayout.Space(5);
  633. EditorGUI.indentLevel++;
  634. GUIContent ObjectDetectionModelLabel = new GUIContent("Object Detection Model", "Select the available object detection model. HUMAN_XXX for skeleton tracking");
  635. OD_DetectionModel.enumValueIndex = (int)(sl.DETECTION_MODEL)EditorGUILayout.EnumPopup(ObjectDetectionModelLabel, (sl.DETECTION_MODEL)OD_DetectionModel.enumValueIndex);
  636. EditorGUI.indentLevel--;
  637. GUILayout.Space(10);
  638. EditorGUILayout.LabelField("Init Parameters", EditorStyles.boldLabel);
  639. GUILayout.Space(5);
  640. EditorGUI.indentLevel++;
  641. GUI.enabled = !cameraIsReady || !manager.IsObjectDetectionRunning;
  642. GUIContent ImageSyncModeLabel = new GUIContent("Image Sync", "If enabled, object detection will be computed for each image before the next frame is available, " +
  643. "locking the main thread if necessary.\r\n\nRecommended setting is false for real-time applications.");
  644. OD_ImageSyncMode.boolValue = EditorGUILayout.Toggle(ImageSyncModeLabel, OD_ImageSyncMode.boolValue);
  645. GUIContent ObjectTrackingLabel = new GUIContent("Enable Object Tracking", "Whether to track objects across multiple frames using the ZED's position relative to the floor.\r\n\n" +
  646. "Requires tracking to be on. It's also recommended to enable Estimate Initial Position to find the floor.");
  647. OD_ObjectTracking.boolValue = EditorGUILayout.Toggle(ObjectTrackingLabel, OD_ObjectTracking.boolValue);
  648. if (OD_DetectionModel.enumValueIndex == (int)sl.DETECTION_MODEL.MULTI_CLASS_BOX || OD_DetectionModel.enumValueIndex == (int)sl.DETECTION_MODEL.MULTI_CLASS_BOX_MEDIUM || OD_DetectionModel.enumValueIndex == (int)sl.DETECTION_MODEL.MULTI_CLASS_BOX_ACCURATE ||
  649. OD_DetectionModel.enumValueIndex == (int)sl.DETECTION_MODEL.CUSTOM_BOX_OBJECTS || OD_DetectionModel.enumValueIndex == (int)sl.DETECTION_MODEL.PERSON_HEAD_BOX)
  650. {
  651. GUIContent Object2DMaskLabel = new GUIContent("Enable 2D Mask", "Whether to calculate 2D masks for each object, showing exactly which pixels within the 2D bounding box are the object.\r\n\n" +
  652. "Must be on when Object Detection starts. Requires more performance, so do not enable unless needed.");
  653. OD_2DMask.boolValue = EditorGUILayout.Toggle(Object2DMaskLabel, OD_2DMask.boolValue);
  654. }
  655. else
  656. {
  657. GUIContent BodyFittingLabel = new GUIContent("Enable Body Fitting", "Defines if the body fitting will be applied.\r\n\n" +
  658. "Requires tracking to be on. It's also recommended to enable Estimate Initial Position to find the floor.");
  659. OD_BodyFitting.boolValue = EditorGUILayout.Toggle(BodyFittingLabel, OD_BodyFitting.boolValue);
  660. }
  661. GUIContent MaxRangeLabel = new GUIContent("Max Range", "Defines a upper depth range for detections.");
  662. OD_MaxRange.floatValue = EditorGUILayout.Slider(MaxRangeLabel, OD_MaxRange.floatValue, 0, 40.0f);
  663. GUIContent FilteringModeLabel = new GUIContent("Filtering Mode", "Defines the bounding box preprocessor used.");
  664. OD_FilteringMode.enumValueIndex = (int)(sl.OBJECT_FILTERING_MODE)EditorGUILayout.EnumPopup(FilteringModeLabel, (sl.OBJECT_FILTERING_MODE)OD_FilteringMode.enumValueIndex);
  665. GUI.enabled = true;
  666. EditorGUI.indentLevel--;
  667. GUILayout.Space(10);
  668. if (OD_DetectionModel.enumValueIndex == (int)sl.DETECTION_MODEL.MULTI_CLASS_BOX || OD_DetectionModel.enumValueIndex == (int)sl.DETECTION_MODEL.MULTI_CLASS_BOX_MEDIUM || OD_DetectionModel.enumValueIndex == (int)sl.DETECTION_MODEL.MULTI_CLASS_BOX_ACCURATE)
  669. {
  670. EditorGUILayout.LabelField("Runtime Parameters", EditorStyles.boldLabel);
  671. GUILayout.Space(5);
  672. EditorGUI.indentLevel++;
  673. GUIContent OD_personDetectionConfidenceThresholdLabel = new GUIContent("Person Confidence Threshold", "Detection sensitivity.Represents how sure the SDK must be that " +
  674. "an object exists to report it.\r\n\nEx: If the threshold is 80, then only objects where the SDK is 80% sure or greater will appear in the list of detected objects.");
  675. OD_PersonDetectionConfidence.intValue = EditorGUILayout.IntSlider(OD_personDetectionConfidenceThresholdLabel, OD_PersonDetectionConfidence.intValue, 1, 99);
  676. GUIContent vehicleDetectionConfidenceThresholdLabel = new GUIContent("Vehicle Confidence Threshold", "Detection sensitivity.Represents how sure the SDK must be that " +
  677. "an object exists to report it.\r\n\nEx: If the threshold is 80, then only objects where the SDK is 80% sure or greater will appear in the list of detected objects.");
  678. OD_VehicleDetectionConfidence.intValue = EditorGUILayout.IntSlider(vehicleDetectionConfidenceThresholdLabel, OD_VehicleDetectionConfidence.intValue, 1, 99);
  679. GUIContent bagDetectionConfidenceThresholdLabel = new GUIContent("Bag Confidence Threshold", "Detection sensitivity.Represents how sure the SDK must be that " +
  680. "an object exists to report it.\r\n\nEx: If the threshold is 80, then only objects where the SDK is 80% sure or greater will appear in the list of detected objects.");
  681. OD_BagDetectionConfidence.intValue = EditorGUILayout.IntSlider(bagDetectionConfidenceThresholdLabel, OD_BagDetectionConfidence.intValue, 1, 99);
  682. GUIContent animalDetectionConfidenceThresholdLabel = new GUIContent("Animal Confidence Threshold", "Detection sensitivity.Represents how sure the SDK must be that " +
  683. "an object exists to report it.\r\n\nEx: If the threshold is 80, then only objects where the SDK is 80% sure or greater will appear in the list of detected objects.");
  684. OD_AnimalDetectionConfidence.intValue = EditorGUILayout.IntSlider(animalDetectionConfidenceThresholdLabel, OD_AnimalDetectionConfidence.intValue, 1, 99);
  685. GUIContent electronicsDetectionConfidenceThresholdLabel = new GUIContent("Electronics Confidence Threshold", "Detection sensitivity.Represents how sure the SDK must be that " +
  686. "an object exists to report it.\r\n\nEx: If the threshold is 80, then only objects where the SDK is 80% sure or greater will appear in the list of detected objects.");
  687. OD_ElectronicsDetectionConfidence.intValue = EditorGUILayout.IntSlider(electronicsDetectionConfidenceThresholdLabel, OD_ElectronicsDetectionConfidence.intValue, 1, 99);
  688. GUIContent fruitVegetableDetectionConfidenceThresholdLabel = new GUIContent("Fruit and Vegetable Confidence Threshold", "Detection sensitivity.Represents how sure the SDK must be that " +
  689. "an object exists to report it.\r\n\nEx: If the threshold is 80, then only objects where the SDK is 80% sure or greater will appear in the list of detected objects.");
  690. OD_FruitVegetableDetectionConfidence.intValue = EditorGUILayout.IntSlider(fruitVegetableDetectionConfidenceThresholdLabel, OD_FruitVegetableDetectionConfidence.intValue, 1, 99);
  691. GUIContent sportDetectionConfidenceThresholdLabel = new GUIContent("Sport Confidence Threshold", "Detection sensitivity.Represents how sure the SDK must be that " +
  692. "an object exists to report it.\r\n\nEx: If the threshold is 80, then only objects where the SDK is 80% sure or greater will appear in the list of detected objects.");
  693. OD_SportDetectionConfidence.intValue = EditorGUILayout.IntSlider(sportDetectionConfidenceThresholdLabel, OD_SportDetectionConfidence.intValue, 1, 99);
  694. GUILayout.Space(5);
  695. GUIContent PersonFilterLabel = new GUIContent("Person Filter", "Whether to detect people during object detection.");
  696. OD_PersonFilter.boolValue = EditorGUILayout.Toggle(PersonFilterLabel, OD_PersonFilter.boolValue);
  697. GUIContent VehicleFilterLabel = new GUIContent("Vehicle Filter", "Whether to detect vehicles during object detection.");
  698. OD_VehicleFilter.boolValue = EditorGUILayout.Toggle(VehicleFilterLabel, OD_VehicleFilter.boolValue);
  699. GUIContent BagFilterLabel = new GUIContent("Bag Filter", "Whether to detect bags during object detection.");
  700. OD_BagFilter.boolValue = EditorGUILayout.Toggle(BagFilterLabel, OD_BagFilter.boolValue);
  701. GUIContent AnimalFilterLabel = new GUIContent("Animal Filter", "Whether to detect animals during object detection.");
  702. OD_AnimalFilter.boolValue = EditorGUILayout.Toggle(AnimalFilterLabel, OD_AnimalFilter.boolValue);
  703. GUIContent ElectronicsFilterLabel = new GUIContent("Electronics Filter", "Whether to detect electronics devices during object detection.");
  704. OD_ElectronicsFilter.boolValue = EditorGUILayout.Toggle(ElectronicsFilterLabel, OD_ElectronicsFilter.boolValue);
  705. GUIContent FruitVegetableFilterLabel = new GUIContent("Fruit and Vegetable Filter", "Whether to detect fruits and vegetablesduring object detection.");
  706. OD_FruitVegetableFilter.boolValue = EditorGUILayout.Toggle(FruitVegetableFilterLabel, OD_FruitVegetableFilter.boolValue);
  707. GUIContent SportFilterLabel = new GUIContent("Sport Filter", "Whether to detect sport related objects during object detection.");
  708. OD_SportFilter.boolValue = EditorGUILayout.Toggle(SportFilterLabel, OD_SportFilter.boolValue);
  709. EditorGUI.indentLevel--;
  710. }
  711. else if (OD_DetectionModel.enumValueIndex == (int)sl.DETECTION_MODEL.PERSON_HEAD_BOX)
  712. {
  713. EditorGUILayout.LabelField("Runtime Parameters", EditorStyles.boldLabel);
  714. GUILayout.Space(5);
  715. EditorGUI.indentLevel++;
  716. GUIContent OD_personDetectionConfidenceThresholdLabel = new GUIContent("Person head Confidence Threshold", "Detection sensitivity.Represents how sure the SDK must be that " +
  717. "an object exists to report it.\r\n\nEx: If the threshold is 80, then only objects where the SDK is 80% sure or greater will appear in the list of detected objects.");
  718. OD_PersonDetectionConfidence.intValue = EditorGUILayout.IntSlider(OD_personDetectionConfidenceThresholdLabel, OD_PersonDetectionConfidence.intValue, 1, 99);
  719. }
  720. else if (OD_DetectionModel.enumValueIndex == (int)sl.DETECTION_MODEL.CUSTOM_BOX_OBJECTS) {
  721. }
  722. else //SKELETON
  723. {
  724. EditorGUILayout.LabelField("Runtime Parameters", EditorStyles.boldLabel);
  725. GUILayout.Space(5);
  726. EditorGUI.indentLevel++;
  727. GUIContent SK_personDetectionConfidenceThresholdLabel = new GUIContent("Person Confidence Threshold", "Detection sensitivity.Represents how sure the SDK must be that " +
  728. "an object exists to report it.\r\n\nEx: If the threshold is 80, then only objects where the SDK is 80% sure or greater will appear in the list of detected objects.");
  729. SK_PersonDetectionConfidence.intValue = EditorGUILayout.IntSlider(SK_personDetectionConfidenceThresholdLabel, SK_PersonDetectionConfidence.intValue, 1, 99);
  730. }
  731. GUI.enabled = cameraIsReady;
  732. GUILayout.Space(10);
  733. if (!manager.IsObjectDetectionRunning)
  734. {
  735. GUIContent startODlabel = new GUIContent("Start Object Detection", "Begin the OD process.");
  736. if (GUILayout.Button(startODlabel))
  737. {
  738. manager.StartObjectDetection();
  739. }
  740. }
  741. else
  742. {
  743. GUIContent stopODlabel = new GUIContent("Stop Object Detection", "Stop the OD process.");
  744. if (GUILayout.Button(stopODlabel))
  745. {
  746. manager.StopObjectDetection();
  747. }
  748. }
  749. GUI.enabled = true;
  750. }
  751. ///////////////////////////////////////////////////////////////
  752. /// Recording layout /////////////////////////////////
  753. /////////////////////////////////////////////////////////////
  754. GUILayout.Space(10);
  755. showRecording.boolValue = EditorGUILayout.Foldout(showRecording.boolValue, "Recording", boldfoldout);
  756. if (showRecording.boolValue)
  757. {
  758. EditorGUI.indentLevel++;
  759. GUILayout.Space(5);
  760. bool cameraIsReady = false;
  761. if (manager)
  762. cameraIsReady = manager.zedCamera != null ? manager.zedCamera.IsCameraReady : false;
  763. GUIContent svoOutFileNameLabel = new GUIContent("SVO File", "SVO file name");
  764. svoOutputFileNameProperty.stringValue = EditorGUILayout.TextField(svoOutFileNameLabel, svoOutputFileNameProperty.stringValue, GUILayout.ExpandWidth(true));
  765. GUIContent svoCompressionModeLabel = new GUIContent("SVO Compression", "SVO Compression mode for the recorded SVO file");
  766. svoOutputCompressionModeProperty.enumValueIndex = (int)(sl.SVO_COMPRESSION_MODE)EditorGUILayout.EnumPopup(svoCompressionModeLabel, (sl.SVO_COMPRESSION_MODE)svoOutputCompressionModeProperty.enumValueIndex, GUILayout.ExpandWidth(true));
  767. GUIContent svoOutBitrateLabel = new GUIContent("Bitrate", "Bitrate for H264/5 recording");
  768. svoOutputBitrateProperty.intValue = EditorGUILayout.IntField(svoOutBitrateLabel, svoOutputBitrateProperty.intValue);
  769. GUIContent svoOutTargetFPSLabel = new GUIContent("Target FPS", "Target FPS for SVO recording");
  770. svoOutputTargetFPSProperty.intValue = EditorGUILayout.IntField(svoOutTargetFPSLabel, svoOutputTargetFPSProperty.intValue);
  771. GUIContent svoOutputTranscodeLabel = new GUIContent("Transcode", "If streaming input, set to false to avoid transcoding (decoding+ re-encoding for SVO). Recommended to leave at false.");
  772. svoOutputTranscodeProperty.boolValue = EditorGUILayout.Toggle(svoOutputTranscodeLabel, svoOutputTranscodeProperty.boolValue);
  773. EditorGUILayout.BeginHorizontal();
  774. GUI.enabled = cameraIsReady;
  775. string recordLabel = manager.needRecordFrame ? "Stop Recording" : "Start Recording";
  776. string recordtooltip = manager.needRecordFrame ? "Stop Recording" : "Start Recording";
  777. GUIContent displaylabel = new GUIContent(recordLabel, recordtooltip);
  778. GUILayout.Space(EditorGUIUtility.labelWidth);
  779. if (GUILayout.Button(recordLabel))
  780. {
  781. if (manager.needRecordFrame)
  782. {
  783. manager.zedCamera.DisableRecording();
  784. manager.needRecordFrame = false;
  785. }
  786. else
  787. {
  788. if (manager.zedCamera.EnableRecording(svoOutputFileNameProperty.stringValue, (sl.SVO_COMPRESSION_MODE)svoOutputCompressionModeProperty.enumValueIndex,(int)svoOutputBitrateProperty.intValue,(int)svoOutputTargetFPSProperty.intValue,svoOutputTranscodeProperty.boolValue) == sl.ERROR_CODE.SUCCESS)
  789. manager.needRecordFrame = true;
  790. else
  791. {
  792. Debug.LogError("Failed to start SVO Recording");
  793. manager.needRecordFrame = false;
  794. }
  795. }
  796. }
  797. EditorGUI.indentLevel--;
  798. GUI.enabled = true;
  799. EditorGUILayout.EndHorizontal();
  800. }
  801. ///////////////////////////////////////////////////////////////
  802. /// Streaming Out layout /////////////////////////////////
  803. /////////////////////////////////////////////////////////////
  804. GUILayout.Space(10);
  805. showStreamingOut.boolValue = EditorGUILayout.Foldout(showStreamingOut.boolValue, "Streaming", boldfoldout);
  806. if (showStreamingOut.boolValue)
  807. {
  808. EditorGUI.indentLevel++;
  809. GUILayout.Space(5);
  810. GUIContent streamingOutPropertyLabel = new GUIContent("Enable Streaming Output", "Enable Streaming Output with below settings");
  811. streamingOutProperty.boolValue = EditorGUILayout.Toggle(streamingOutPropertyLabel, streamingOutProperty.boolValue);
  812. GUIContent streamingOutCodecPropertyLabel = new GUIContent("Codec", "Codec used for images compression");
  813. streamingOutCodecProperty.enumValueIndex = (int)(sl.STREAMING_CODEC)EditorGUILayout.EnumPopup(streamingOutCodecPropertyLabel, (sl.STREAMING_CODEC)streamingOutCodecProperty.enumValueIndex);
  814. GUIContent streamingOutPortPropertyLabel = new GUIContent("Port", "Port where stream is sent to ");
  815. streamingOutPortProperty.intValue = EditorGUILayout.IntField(streamingOutPortPropertyLabel, streamingOutPortProperty.intValue);
  816. GUIContent streamingOutBitratePropertyLabel = new GUIContent("Bitrate", "Target Bitrate for the codec");
  817. streamingOutBitrateProperty.intValue = EditorGUILayout.IntField(streamingOutBitratePropertyLabel, streamingOutBitrateProperty.intValue);
  818. GUIContent streamingOutGopSizePropertyLabel = new GUIContent("Gop", "Maximum Gop size for the codec");
  819. streamingOutGopSizeProperty.intValue = EditorGUILayout.IntField(streamingOutGopSizePropertyLabel, streamingOutGopSizeProperty.intValue);
  820. GUIContent streamingOutAdaptBitratePropertyLabel = new GUIContent("Adaptative Bitrate", "Adaptative bitrate for the codec");
  821. streamingOutAdaptBitrateProperty.boolValue = EditorGUILayout.Toggle(streamingOutAdaptBitratePropertyLabel, streamingOutAdaptBitrateProperty.boolValue);
  822. GUIContent streamingOutChunkSizePropertyLabel = new GUIContent("Payload", "Chunk size for packet streaming");
  823. streamingOutChunkSizeProperty.intValue = EditorGUILayout.IntField(streamingOutChunkSizePropertyLabel, streamingOutChunkSizeProperty.intValue);
  824. GUIContent streamingOutTargetFPSPropertyLabel = new GUIContent("Target FPS", "Target FPS for streaming output");
  825. streamingOutTargetFPSProperty.intValue = EditorGUILayout.IntField(streamingOutTargetFPSPropertyLabel, streamingOutTargetFPSProperty.intValue);
  826. EditorGUI.indentLevel--;
  827. }
  828. ///////////////////////////////////////////////////////////////
  829. /// Advanced Settings layout ///////////////////////////////
  830. /////////////////////////////////////////////////////////////
  831. GUILayout.Space(10);
  832. showadvanced.boolValue = EditorGUILayout.Foldout(showadvanced.boolValue, "Advanced Settings", boldfoldout);
  833. if (showadvanced.boolValue)
  834. {
  835. EditorGUI.indentLevel++;
  836. GUILayout.Space(5);
  837. GUIContent sensingModeLabel = new GUIContent("Sensing Mode", "FILL approximates depth in areas where depth can't be measured. " +
  838. "FILL is almost always better for augmented/mixed reality applications.");
  839. sensingModeProperty.enumValueIndex = (int)(sl.SENSING_MODE)EditorGUILayout.EnumPopup(sensingModeLabel, (sl.SENSING_MODE)sensingModeProperty.enumValueIndex);
  840. GUIContent maxDepthPropertyLabel = new GUIContent("Max Depth Range", "Maximum depth at which the camera will display the real world, in meters. " +
  841. "Pixels further than this value will be invisible.");
  842. maxDepthProperty.floatValue = EditorGUILayout.Slider(maxDepthPropertyLabel, maxDepthProperty.floatValue, 0f, 40f);
  843. GUIContent confidenceThresholdPropertyLabel = new GUIContent("Confidence Threshold", "How tolerant the ZED SDK is to low confidence values. Lower values filter more pixels based on stereo matching score.");
  844. if (Application.isPlaying)
  845. {
  846. manager.confidenceThreshold = EditorGUILayout.IntSlider(confidenceThresholdPropertyLabel, manager.confidenceThreshold, 0, 100);
  847. }
  848. else
  849. {
  850. confidenceThresholdProperty.intValue = EditorGUILayout.IntSlider(confidenceThresholdPropertyLabel, confidenceThresholdProperty.intValue, 0, 100);
  851. }
  852. GUIContent textureConfidenceThresholdPropertyLabel = new GUIContent("Texture Confidence Threshold", "How tolerant the ZED SDK is to homogenous block. Lower values filter more pixels based on textureness.");
  853. if (Application.isPlaying)
  854. {
  855. manager.textureConfidenceThreshold = EditorGUILayout.IntSlider(textureConfidenceThresholdPropertyLabel, manager.textureConfidenceThreshold, 0, 100);
  856. }
  857. else
  858. {
  859. textureConfidenceThresholdProperty.intValue = EditorGUILayout.IntSlider(textureConfidenceThresholdPropertyLabel, textureConfidenceThresholdProperty.intValue, 0, 100);
  860. }
  861. GUILayout.Space(12);
  862. //Enable image enhancement toggle
  863. EditorGUI.BeginDisabledGroup(Application.isPlaying);
  864. GUIContent imageenhancementlabel = new GUIContent("Image Enhancement", "Whether to enable the new color/gamma curve added to the ZED SDK in v3.0.\r\n" +
  865. "Exposes more detail in darker regions and removes a slight red bias.");
  866. enableImageEnhancementProperty.boolValue = EditorGUILayout.Toggle(imageenhancementlabel, manager.enableImageEnhancement);
  867. EditorGUI.EndDisabledGroup();
  868. GUIContent enalbeIMUFusionLabel = new GUIContent("Visual-Inertial Tracking", "If true, and you are using a ZED2 or ZED Mini, IMU fusion uses data from the camera's IMU to improve tracking results. ");
  869. enableIMUFusionProperty.boolValue = EditorGUILayout.Toggle(enalbeIMUFusionLabel, enableIMUFusionProperty.boolValue);
  870. //Whether to enable the ZED SDK's self-calibration feature.
  871. GUIContent enableselfcaliblabel = new GUIContent("Self-Calibration", "If true, the ZED SDK will subtly adjust the ZED's calibration " +
  872. "during runtime to account for heat and other factors. Reasons to disable this are rare. ");
  873. enableSelfCalibrationProperty.boolValue = EditorGUILayout.Toggle(enableselfcaliblabel, enableSelfCalibrationProperty.boolValue);
  874. //Grey Skybox toggle.
  875. GUIContent greyskyboxlabel = new GUIContent("Grey Out Skybox on Start", "True to set the background to a neutral gray when the scene starts.\n\r" +
  876. "Recommended for AR so that lighting on virtual objects better matches the real world.");
  877. greyskybox.boolValue = EditorGUILayout.Toggle(greyskyboxlabel, manager.greySkybox);
  878. //Don't Destroy On Load toggle.
  879. GUIContent dontdestroylabel = new GUIContent("Don't Destroy on Load", "When enabled, applies DontDestroyOnLoad() on the ZED rig in Awake(), " +
  880. "preserving it between scene transitions.");
  881. dontdestroyonload.boolValue = EditorGUILayout.Toggle(dontdestroylabel, manager.dontDestroyOnLoad);
  882. GUIContent openCalibPathlabel = new GUIContent("Opencv Calibration File ", "Optional, Set an optional file path where the SDK can find a file containing the calibration information of the camera computed by OpenCV. ");
  883. opencvCalibFilePath.stringValue = EditorGUILayout.TextField(openCalibPathlabel, opencvCalibFilePath.stringValue);
  884. GUILayout.Space(12);
  885. EditorGUI.indentLevel--;
  886. EditorGUILayout.LabelField("AR Passthrough Settings", EditorStyles.boldLabel);
  887. GUILayout.Space(5);
  888. EditorGUI.indentLevel++;
  889. //Style for the AR layer box.
  890. GUIStyle layerboxstyle = new GUIStyle(EditorStyles.numberField);
  891. layerboxstyle.fixedWidth = 30;
  892. layerboxstyle.stretchWidth = false;
  893. layerboxstyle.alignment = TextAnchor.MiddleCenter;
  894. GUIStyle layerboxstylewarning = new GUIStyle(layerboxstyle);
  895. layerboxstylewarning.normal.textColor = new Color(.9f, .9f, 0); //Red color if layer number is invalid.
  896. GUIStyle layerboxstyleerror = new GUIStyle(layerboxstyle);
  897. layerboxstyleerror.normal.textColor = new Color(.8f, 0, 0); //Red color if layer number is invalid.
  898. GUIContent arlayerlabel = new GUIContent("AR Layer", "Layer that a final, normally-hidden AR rig sees. Used to confine it from the rest of the scene.\r\n " +
  899. "You can assign this to any empty layer, and multiple ZEDs can share the same layer.");
  900. arlayer = EditorGUILayout.IntField(arlayerlabel, ZEDLayers.arlayer, arlayer < 32 ? layerboxstyle : layerboxstyleerror);
  901. //Show an error message if the set layer is invalid.
  902. GUIStyle errormessagestyle = new GUIStyle(EditorStyles.label);
  903. errormessagestyle.normal.textColor = layerboxstyleerror.normal.textColor;
  904. errormessagestyle.wordWrap = true;
  905. errormessagestyle.fontSize = 10;
  906. //Show small error message if user set layer to below zero.
  907. if (arlayer < 0)
  908. {
  909. string errortext = "Unity layers must be above zero to be visible.";
  910. Rect labelrect = GUILayoutUtility.GetRect(new GUIContent(errortext, ""), errormessagestyle);
  911. EditorGUI.LabelField(labelrect, errortext, errormessagestyle);
  912. }
  913. //Show small error message if user set layer higher than 31, which is invalid because Unity layers only go up to 31.
  914. if (arlayer > 31)
  915. {
  916. string errortext = "Unity doesn't support layers above 31.";
  917. Rect labelrect = GUILayoutUtility.GetRect(new GUIContent(errortext, ""), errormessagestyle);
  918. EditorGUI.LabelField(labelrect, errortext, errormessagestyle);
  919. }
  920. //Show warnings if the layer is valid but not recommended.
  921. GUIStyle warningmessagestyle = new GUIStyle(EditorStyles.label);
  922. warningmessagestyle.normal.textColor = layerboxstylewarning.normal.textColor;
  923. warningmessagestyle.wordWrap = true;
  924. warningmessagestyle.fontSize = 10;
  925. //Show small warning message if user set layer to 31, which is technically valid but Unity reserves it for other uses.
  926. if (arlayer == 31)
  927. {
  928. string warningext = "Warning: Unity reserves layer 31 for previews in the editor. Assigning to layer 31 can cause conflicts.";
  929. Rect labelrect = GUILayoutUtility.GetRect(new GUIContent(warningext, ""), warningmessagestyle);
  930. EditorGUI.LabelField(labelrect, warningext, warningmessagestyle);
  931. }
  932. //Show small warning message if user set layer to 0
  933. if (arlayer == 0)
  934. {
  935. string warningext = "Warning: Setting the AR rig to see the Default layer means other objects will be drawn in the background, " +
  936. "and in unexpected positions as the AR rig position is not synced with the ZED_Rig_Stereo object.";
  937. Rect labelrect = GUILayoutUtility.GetRect(new GUIContent(warningext, ""), warningmessagestyle);
  938. EditorGUI.LabelField(labelrect, warningext, warningmessagestyle);
  939. }
  940. ZEDLayersManager.ClearLayer(ZEDLayers.ID_arlayer);
  941. ZEDLayersManager.CreateLayer(ZEDLayers.ID_arlayer, arlayer);
  942. //Show AR Rig toggle.
  943. GUIContent showarlabel = new GUIContent("Show Final AR Rig", "Whether to show the hidden camera rig used in stereo AR mode to " +
  944. "prepare images for HMD output. You normally shouldn't tamper with this rig, but seeing it can be useful for " +
  945. "understanding how the ZED output works.");
  946. bool lastshowar = manager.showARRig;
  947. showarrig.boolValue = EditorGUILayout.Toggle(showarlabel, manager.showARRig);
  948. if (showarrig.boolValue != lastshowar)
  949. {
  950. LayerMask arlayers = (1 << manager.arLayer);
  951. if (showarrig.boolValue == true)
  952. {
  953. Tools.visibleLayers |= arlayers;
  954. }
  955. else
  956. {
  957. Tools.visibleLayers &= ~(arlayers);
  958. }
  959. if (manager.zedRigDisplayer != null && Application.isPlaying)
  960. {
  961. manager.zedRigDisplayer.hideFlags = showarrig.boolValue ? HideFlags.None : HideFlags.HideInHierarchy;
  962. }
  963. }
  964. //GUILayout.Space(12);
  965. EditorGUI.BeginDisabledGroup(Application.isPlaying);
  966. GUIContent rightDepthLabel = new GUIContent("Enable Right Depth", "Whether to enable depth measurements from the right camera. Required for depth effects in AR pass-through, " +
  967. "but requires performance even if not used.\r\n\n'AUTO' enables it only if a ZEDRenderingPlane component set to the right eye is detected as a child of ZEDManager's " +
  968. "GameObject (as in the ZED rig prefabs.)");
  969. rightDepthProperty.enumValueIndex = (int)(ZEDManager.RightDepthEnabledMode)EditorGUILayout.EnumPopup(rightDepthLabel, (ZEDManager.RightDepthEnabledMode)rightDepthProperty.enumValueIndex);
  970. GUIContent allowPassThroughLabel = new GUIContent("Allow AR Pass-Through", "If true, the ZED rig will enter 'pass-through' mode if it detects a stereo rig - at least " +
  971. "two cameras as children with ZEDRenderingPlane components, each with a different eye) - and a VR headset is connected. If false, it will never enter pass-through mode.");
  972. allowPassThroughProperty.boolValue = EditorGUILayout.Toggle(allowPassThroughLabel, allowPassThroughProperty.boolValue);
  973. //Whether to set the IMU prior in AR passthrough mode.
  974. GUIContent setimupriorlabel = new GUIContent("Set IMU Prior in AR", "In AR pass-through mode, whether to compare the " +
  975. "ZED's IMU data against the reported position of the VR headset. This helps compensate for drift and should " +
  976. "usually be left on. However, in some setups, like when using a custom mount, this can cause tracking errors.");
  977. setIMUPrior.boolValue = EditorGUILayout.Toggle(setimupriorlabel, manager.setIMUPriorInAR);
  978. //Fade In At Start toggle.
  979. GUIContent fadeinlabel = new GUIContent("Fade In at Start", "When enabled, makes the ZED image fade in from black when the application starts.");
  980. fadeinonstart.boolValue = EditorGUILayout.Toggle(fadeinlabel, manager.fadeInOnStart);
  981. GUILayout.Space(12);
  982. GUI.enabled = true;
  983. GUIContent camRebootButton = new GUIContent("Reboot Camera", "Reboot the camera.");
  984. if (GUILayout.Button(camRebootButton))
  985. {
  986. if (Application.isPlaying && manager.zedCamera.IsCameraReady)
  987. {
  988. manager.Reboot();
  989. }
  990. }
  991. EditorGUI.EndDisabledGroup();
  992. EditorGUI.indentLevel--;
  993. }
  994. serializedObject.ApplyModifiedProperties();
  995. ///////////////////////////////////////////////////////////////
  996. /// Camera control layout ///////////////////////////////////
  997. /////////////////////////////////////////////////////////////
  998. /*//TEST: Try loading starting settings.
  999. if (Application.isPlaying && manager.zedCamera.IsCameraReady)
  1000. {
  1001. if (!hasLoadedSettings)
  1002. {
  1003. Debug.Log("Loaded settings.");
  1004. LoadCurrentVideoSettings();
  1005. hasLoadedSettings = true;
  1006. }
  1007. }
  1008. else hasLoadedSettings = false;*/
  1009. GUILayout.Space(10);
  1010. showcamcontrol.boolValue = EditorGUILayout.Foldout(showcamcontrol.boolValue, "Camera Controls", boldfoldout);
  1011. if (showcamcontrol.boolValue)
  1012. {
  1013. GUILayout.Space(5);
  1014. EditorGUI.indentLevel++;
  1015. //usbResolutionProperty.enumValueIndex = (int)(sl.RESOLUTION)EditorGUILayout.EnumPopup(cameraResolutionLabel, (sl.RESOLUTION)usbResolutionProperty.enumValueIndex);
  1016. //(ZEDManager.VideoSettingsInitMode)
  1017. GUIContent videoInitModeLabel = new GUIContent("Load From: ", "Where the ZED's settings come from when you start the scene.\r\n\n" +
  1018. "- Custom: Applies settings as set below before runtime.\r\n\n- Load From SDK: Camera will load settings last applied to the ZED. " +
  1019. "May have been from a source outside Unity.\r\n\n- Default: Camera will load default video settings.");
  1020. videoSettingsInitModeProperty.enumValueIndex = (int)(ZEDManager.VideoSettingsInitMode)EditorGUILayout.EnumPopup(videoInitModeLabel,
  1021. (ZEDManager.VideoSettingsInitMode)videoSettingsInitModeProperty.enumValueIndex);
  1022. if (manager.zedCamera == null && videoSettingsInitModeProperty.enumValueIndex != (int)ZEDManager.VideoSettingsInitMode.Custom)
  1023. GUI.enabled = false;
  1024. else
  1025. GUI.enabled = true;
  1026. EditorGUI.BeginChangeCheck();
  1027. brightnessProperty.intValue = EditorGUILayout.IntSlider("Brightness", brightnessProperty.intValue, 0, 8);
  1028. if (EditorGUI.EndChangeCheck())
  1029. {
  1030. if (manager.zedCamera != null && manager.zedCamera.IsCameraReady)
  1031. manager.zedCamera.SetCameraSettings(sl.CAMERA_SETTINGS.BRIGHTNESS, brightnessProperty.intValue);
  1032. }
  1033. EditorGUI.BeginChangeCheck();
  1034. contrastProperty.intValue = EditorGUILayout.IntSlider("Contrast", contrastProperty.intValue, 0, 8);
  1035. if (EditorGUI.EndChangeCheck())
  1036. {
  1037. if (manager.zedCamera != null && manager.zedCamera.IsCameraReady)
  1038. manager.zedCamera.SetCameraSettings(sl.CAMERA_SETTINGS.CONTRAST, contrastProperty.intValue);
  1039. }
  1040. EditorGUI.BeginChangeCheck();
  1041. hueProperty.intValue = EditorGUILayout.IntSlider("Hue", hueProperty.intValue, 0, 11);
  1042. if (EditorGUI.EndChangeCheck())
  1043. {
  1044. if (manager.zedCamera != null && manager.zedCamera.IsCameraReady)
  1045. manager.zedCamera.SetCameraSettings(sl.CAMERA_SETTINGS.HUE, hueProperty.intValue);
  1046. }
  1047. EditorGUI.BeginChangeCheck();
  1048. saturationProperty.intValue = EditorGUILayout.IntSlider("Saturation", saturationProperty.intValue, 0, 8);
  1049. if (EditorGUI.EndChangeCheck())
  1050. {
  1051. if (manager.zedCamera != null && manager.zedCamera.IsCameraReady)
  1052. manager.zedCamera.SetCameraSettings(sl.CAMERA_SETTINGS.SATURATION, saturationProperty.intValue);
  1053. }
  1054. EditorGUI.BeginChangeCheck();
  1055. sharpnessProperty.intValue = EditorGUILayout.IntSlider("Sharpness", sharpnessProperty.intValue, 0, 8);
  1056. if (EditorGUI.EndChangeCheck())
  1057. {
  1058. if (manager.zedCamera != null && manager.zedCamera.IsCameraReady)
  1059. manager.zedCamera.SetCameraSettings(sl.CAMERA_SETTINGS.SHARPNESS, sharpnessProperty.intValue);
  1060. }
  1061. EditorGUI.BeginChangeCheck();
  1062. gammaProperty.intValue = EditorGUILayout.IntSlider("Gamma", gammaProperty.intValue, 1, 9);
  1063. if (EditorGUI.EndChangeCheck())
  1064. {
  1065. if (manager.zedCamera != null && manager.zedCamera.IsCameraReady)
  1066. manager.zedCamera.SetCameraSettings(sl.CAMERA_SETTINGS.GAMMA, gammaProperty.intValue);
  1067. }
  1068. EditorGUI.BeginChangeCheck();
  1069. ledStatus.boolValue = EditorGUILayout.Toggle("LED Status", ledStatus.boolValue, EditorStyles.toggle);
  1070. if (EditorGUI.EndChangeCheck())
  1071. {
  1072. if (manager.zedCamera != null && manager.zedCamera.IsCameraReady)
  1073. {
  1074. int lst = ledStatus.boolValue ? 1 : 0;
  1075. manager.zedCamera.SetCameraSettings(sl.CAMERA_SETTINGS.LED_STATUS, lst);
  1076. }
  1077. }
  1078. EditorGUI.BeginChangeCheck();
  1079. autoGainExposureProperty.boolValue = EditorGUILayout.Toggle("AEC / AGC ", autoGainExposureProperty.boolValue, EditorStyles.toggle);
  1080. if (Application.isPlaying && manager.zedCamera != null && manager.zedCamera.IsCameraReady)
  1081. {
  1082. if (EditorGUI.EndChangeCheck())
  1083. {
  1084. if (autoGainExposureProperty.boolValue)
  1085. {
  1086. manager.zedCamera.SetCameraSettings(sl.CAMERA_SETTINGS.AEC_AGC, 1);
  1087. }
  1088. else
  1089. {
  1090. manager.zedCamera.SetCameraSettings(sl.CAMERA_SETTINGS.AEC_AGC, 0);
  1091. gainProperty.intValue = manager.zedCamera.GetCameraSettings(sl.CAMERA_SETTINGS.GAIN);
  1092. exposureProperty.intValue = manager.zedCamera.GetCameraSettings(sl.CAMERA_SETTINGS.EXPOSURE);
  1093. manager.zedCamera.SetCameraSettings(sl.CAMERA_SETTINGS.GAIN, gainProperty.intValue); //Apply last settings immediately.
  1094. manager.zedCamera.SetCameraSettings(sl.CAMERA_SETTINGS.EXPOSURE, exposureProperty.intValue);
  1095. }
  1096. }
  1097. }
  1098. GUI.enabled = !autoGainExposureProperty.boolValue;
  1099. EditorGUI.BeginChangeCheck();
  1100. EditorGUI.indentLevel++;
  1101. gainProperty.intValue = EditorGUILayout.IntSlider("Gain", gainProperty.intValue, 0, 100);
  1102. if (EditorGUI.EndChangeCheck())
  1103. {
  1104. if (manager.zedCamera != null && !autoGainExposureProperty.boolValue)
  1105. {
  1106. manager.zedCamera.SetCameraSettings(sl.CAMERA_SETTINGS.GAIN, gainProperty.intValue);
  1107. }
  1108. }
  1109. EditorGUI.BeginChangeCheck();
  1110. exposureProperty.intValue = EditorGUILayout.IntSlider("Exposure", exposureProperty.intValue, 0, 100);
  1111. if (EditorGUI.EndChangeCheck())
  1112. {
  1113. if (manager.zedCamera != null && manager.zedCamera.IsCameraReady && !autoGainExposureProperty.boolValue)
  1114. {
  1115. manager.zedCamera.SetCameraSettings(sl.CAMERA_SETTINGS.EXPOSURE, exposureProperty.intValue);
  1116. }
  1117. }
  1118. if (manager.zedCamera == null && videoSettingsInitModeProperty.enumValueIndex != (int)ZEDManager.VideoSettingsInitMode.Custom)
  1119. GUI.enabled = false;
  1120. else
  1121. GUI.enabled = true;
  1122. EditorGUI.indentLevel--;
  1123. EditorGUI.BeginChangeCheck();
  1124. autoWhiteBalanceProperty.boolValue = EditorGUILayout.Toggle(" AWB ", autoWhiteBalanceProperty.boolValue, EditorStyles.toggle);
  1125. if (Application.isPlaying && manager.zedCamera.IsCameraReady)
  1126. {
  1127. if (EditorGUI.EndChangeCheck())
  1128. {
  1129. if (autoWhiteBalanceProperty.boolValue)
  1130. {
  1131. manager.zedCamera.SetCameraSettings(sl.CAMERA_SETTINGS.AUTO_WHITEBALANCE, 1);
  1132. }
  1133. else
  1134. {
  1135. manager.zedCamera.SetCameraSettings(sl.CAMERA_SETTINGS.AUTO_WHITEBALANCE, 0);
  1136. whitebalanceProperty.intValue = manager.zedCamera.GetCameraSettings(sl.CAMERA_SETTINGS.WHITEBALANCE) * 100;
  1137. manager.zedCamera.SetCameraSettings(sl.CAMERA_SETTINGS.WHITEBALANCE, whitebalanceProperty.intValue / 100);
  1138. }
  1139. }
  1140. }
  1141. EditorGUI.indentLevel++;
  1142. GUI.enabled = !autoWhiteBalanceProperty.boolValue;
  1143. EditorGUI.BeginChangeCheck();
  1144. whitebalanceProperty.intValue = 100 * EditorGUILayout.IntSlider("White balance", whitebalanceProperty.intValue / 100, 26, 65);
  1145. if (!autoWhiteBalanceProperty.boolValue && EditorGUI.EndChangeCheck())
  1146. {
  1147. if (manager.zedCamera != null && manager.zedCamera.IsCameraReady)
  1148. manager.zedCamera.SetCameraSettings(sl.CAMERA_SETTINGS.WHITEBALANCE, whitebalanceProperty.intValue);
  1149. }
  1150. EditorGUI.indentLevel--;
  1151. EditorGUI.indentLevel--;
  1152. GUILayout.Space(7);
  1153. if (manager.zedCamera == null && videoSettingsInitModeProperty.enumValueIndex != (int)ZEDManager.VideoSettingsInitMode.Custom)
  1154. GUI.enabled = false;
  1155. else
  1156. GUI.enabled = true;
  1157. EditorGUILayout.BeginHorizontal();
  1158. GUILayout.Space(EditorGUIUtility.labelWidth);
  1159. GUIContent camcontrolbuttonreset = new GUIContent("Reset to Default", "Reset camera controls to default.");
  1160. if (GUILayout.Button(camcontrolbuttonreset))
  1161. {
  1162. if (Application.isPlaying && manager.zedCamera.IsCameraReady)
  1163. {
  1164. manager.zedCamera.ResetCameraSettings();
  1165. LoadCurrentVideoSettings();
  1166. }
  1167. else
  1168. {
  1169. brightnessProperty.intValue = sl.ZEDCamera.brightnessDefault;
  1170. contrastProperty.intValue = sl.ZEDCamera.contrastDefault;
  1171. hueProperty.intValue = sl.ZEDCamera.hueDefault;
  1172. saturationProperty.intValue = sl.ZEDCamera.saturationDefault;
  1173. autoGainExposureProperty.boolValue = true;
  1174. autoWhiteBalanceProperty.boolValue = true;
  1175. sharpnessProperty.intValue = sl.ZEDCamera.sharpnessDefault;
  1176. gammaProperty.intValue = sl.ZEDCamera.gammaDefault;
  1177. ledStatus.boolValue = true;
  1178. }
  1179. }
  1180. EditorGUILayout.EndHorizontal();
  1181. GUI.enabled = true;
  1182. }
  1183. serializedObject.ApplyModifiedProperties();
  1184. ///////////////////////////////////////////////////////////////
  1185. /// Status layout //////////////////////////////////////////
  1186. /////////////////////////////////////////////////////////////
  1187. serializedObject.ApplyModifiedProperties();
  1188. GUIStyle standardStyle = new GUIStyle(EditorStyles.textField);
  1189. GUIStyle errorStyle = new GUIStyle(EditorStyles.textField);
  1190. errorStyle.normal.textColor = Color.red;
  1191. GUILayout.Space(10);
  1192. EditorGUILayout.LabelField("Status", EditorStyles.boldLabel);
  1193. EditorGUI.BeginDisabledGroup(true);
  1194. EditorGUI.indentLevel++;
  1195. GUILayout.Space(5);
  1196. GUIContent cameraModellabel = new GUIContent("Camera Model:", "Model of the targeted camera.");
  1197. EditorGUILayout.TextField(cameraModellabel, manager.cameraModel);
  1198. GUIContent cameraSerialNumberlabel = new GUIContent("Camera S/N:", "Serial number of the targeted camera.");
  1199. EditorGUILayout.TextField(cameraSerialNumberlabel, manager.cameraSerialNumber);
  1200. GUIContent cameraFWlabel = new GUIContent("Camera Firmware:", "Firmware of the targeted camera.");
  1201. EditorGUILayout.TextField(cameraFWlabel, manager.cameraFirmware);
  1202. GUIContent sdkversionlabel = new GUIContent("SDK Version:", "Version of the installed ZED SDK.");
  1203. EditorGUILayout.TextField(sdkversionlabel, manager.versionZED);
  1204. GUIContent enginefpslabel = new GUIContent("Engine FPS:", "How many frames per second the engine is rendering.");
  1205. EditorGUILayout.TextField(enginefpslabel, manager.engineFPS);
  1206. GUIContent camerafpslabel = new GUIContent("Camera FPS:", "How many images per second are received from the ZED.");
  1207. EditorGUILayout.TextField(camerafpslabel, manager.cameraFPS);
  1208. GUIContent trackingstatelabel = new GUIContent("Tracking State:", "Whether the ZED's tracking is on, off, or searching (lost position, trying to recover).");
  1209. if (manager.IsCameraTracked || !manager.IsZEDReady)
  1210. EditorGUILayout.TextField(trackingstatelabel, manager.trackingState, standardStyle);
  1211. else
  1212. EditorGUILayout.TextField(trackingstatelabel, manager.trackingState, errorStyle);
  1213. GUIContent odfpslabel = new GUIContent("Obj Detection FPS:", "How many images per second are used for OD");
  1214. EditorGUILayout.TextField(odfpslabel, manager.objectDetectionFPS);
  1215. EditorGUI.indentLevel--;
  1216. EditorGUI.EndDisabledGroup();
  1217. }
  1218. /// <summary>
  1219. /// Check if something has changed that requires restarting the camera.
  1220. /// Used to know if the Restart Camera button and a prompt to press it should be visible.
  1221. /// </summary>
  1222. /// <returns>True if a setting was changed that won't go into effect until a restart. </returns>
  1223. private bool CheckChange()
  1224. {
  1225. if (resolution != manager.resolution ||
  1226. depthmode != manager.depthMode)
  1227. {
  1228. return true;
  1229. }
  1230. else return false;
  1231. }
  1232. /// <summary>
  1233. /// If the given layer name is equal to the provided string, it clears it.
  1234. /// Used when a ZED layer is moved to a different layer.
  1235. /// </summary>
  1236. /// <param name="layer"></param>
  1237. /// <param name="constname"></param>
  1238. private void ClearLayerNameIfNeeded(int layer, string constname)
  1239. {
  1240. if (layer < 0 || layer > 31) return; //Invalid ID.
  1241. SerializedObject tagManager = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset")[0]);
  1242. SerializedProperty layerNames = tagManager.FindProperty("layers");
  1243. if (layerNames.GetArrayElementAtIndex(layer).stringValue == constname)
  1244. {
  1245. layerNames.GetArrayElementAtIndex(layer).stringValue = "";
  1246. tagManager.ApplyModifiedProperties();
  1247. }
  1248. }
  1249. /// <summary>
  1250. /// Loads all current camera video settings from the ZED SDK into the buffer values (brightness, contrast, etc.)
  1251. /// </summary>
  1252. private void LoadCurrentVideoSettings()
  1253. {
  1254. brightnessProperty.intValue = manager.zedCamera.GetCameraSettings(sl.CAMERA_SETTINGS.BRIGHTNESS);
  1255. contrastProperty.intValue = manager.zedCamera.GetCameraSettings(sl.CAMERA_SETTINGS.CONTRAST);
  1256. hueProperty.intValue = manager.zedCamera.GetCameraSettings(sl.CAMERA_SETTINGS.HUE);
  1257. saturationProperty.intValue = manager.zedCamera.GetCameraSettings(sl.CAMERA_SETTINGS.SATURATION);
  1258. sharpnessProperty.intValue = manager.zedCamera.GetCameraSettings(sl.CAMERA_SETTINGS.SHARPNESS);
  1259. gammaProperty.intValue = manager.zedCamera.GetCameraSettings(sl.CAMERA_SETTINGS.GAMMA);
  1260. gainProperty.intValue = manager.zedCamera.GetCameraSettings(sl.CAMERA_SETTINGS.GAIN);
  1261. exposureProperty.intValue = manager.zedCamera.GetCameraSettings(sl.CAMERA_SETTINGS.EXPOSURE);
  1262. whitebalanceProperty.intValue = manager.zedCamera.GetCameraSettings(sl.CAMERA_SETTINGS.WHITEBALANCE);
  1263. autoGainExposureProperty.boolValue = manager.zedCamera.GetCameraSettings(sl.CAMERA_SETTINGS.AEC_AGC) == 1 ? true : false;
  1264. autoWhiteBalanceProperty.boolValue = manager.zedCamera.GetCameraSettings(sl.CAMERA_SETTINGS.AUTO_WHITEBALANCE) == 1 ? true : false;
  1265. ledStatus.boolValue = manager.zedCamera.GetCameraSettings(sl.CAMERA_SETTINGS.LED_STATUS) == 1 ? true : false;
  1266. }
  1267. }