private void FillFromPreset(DetectorProperties source) { if (!IsValue(fieldOffsetX.text)) { preset.properties.detector.offset.x = source.offset.x; } if (!IsValue(fieldOffsetY.text)) { preset.properties.detector.offset.y = source.offset.y; } if (!IsValue(fieldPixelSizeX.text)) { preset.properties.detector.pixelSize.x = source.pixelSize.x; } if (!IsValue(fieldPixelSizeY.text)) { preset.properties.detector.pixelSize.y = source.pixelSize.y; } if (!IsValue(fieldResolutionX.text)) { preset.properties.detector.resolution.x = source.resolution.x; } if (!IsValue(fieldResolutionY.text)) { preset.properties.detector.resolution = source.resolution; } if (!IsValue(fieldDistToSample.text)) { preset.properties.detector.distToSample = source.distToSample; } RefreshDetectorPropertiesUI(); }
public Properties() { absorption = AbsorptionProperties.Initialize(); sample = SampleProperties.Initialize(); ray = RayProperties.Initialize(); detector = DetectorProperties.Initialize(); angle = AngleProperties.Initialize(); }
public Properties(AbsorptionProperties absorptionProperties, AngleProperties angleProperties, DetectorProperties detectorProperties, RayProperties rayProperties, SampleProperties sampleProperties) { absorption = absorptionProperties; sample = sampleProperties; ray = rayProperties; detector = detectorProperties; angle = angleProperties; }
private void InitDetector() { detectorProperties = new DetectorProperties(); detectorProperties.chroma = 0; detectorResult = new DetectorResult(); //we need different focal, then the camera gives us, since we are scaling... float fovy = this.webcamFovY; float gameFovy = fovy; float textureAspect = (float)texture.width / (float)texture.height; float screenAspect = (float)Screen.width / (float)Screen.height; if (textureAspect < screenAspect) { //only if the texture is higher then we got float texHeight = 1.0f; float screenHeight = textureAspect / screenAspect; float focal_length = texHeight / (2 * Mathf.Tan(fovy * Mathf.Deg2Rad * 0.5f)); Debug.Log("Focal length: " + focal_length); //ok now compute game fov gameFovy = 2 * Mathf.Rad2Deg * Mathf.Atan2(screenHeight / 2, focal_length); } GetComponent <Camera>().fieldOfView = gameFovy; // Create unmanaged UMF detector Debug.LogError("Camera params: " + GetComponent <Camera>().near + " far: " + GetComponent <Camera>().far + " fov: " + GetComponent <Camera>().fieldOfView); int createResult = UMF_CreateDetector(texture.width, texture.height, GetComponent <Camera>().near, GetComponent <Camera>().far, fovy * Mathf.Deg2Rad, ref detectorProperties); Debug.Log("Detector allocated with result" + createResult); int changeMarkerResult = UMF_SetMarkerStr(ref detectorProperties, markerCSV.text); Debug.Log("Marker changed to with result: " + changeMarkerResult); }
private static extern int UMF_SetMarkerStr(ref DetectorProperties props, [MarshalAs(UnmanagedType.LPStr)] string str);
private static extern void UMF_FreeDetector(ref DetectorProperties detector);
private static extern int UMF_CreateDetector(int width, int height, float near, float far, float fov, ref DetectorProperties props);
private static extern void UMF_GetResult(ref DetectorProperties detector, ref DetectorResult result);
private static extern int UMF_Detect(ref DetectorProperties detector, float timeout);
private static extern int UMF_SetFrame(ref DetectorProperties detector, byte[] arr);