Ejemplo n.º 1
0
        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();
        }
Ejemplo n.º 2
0
 public Properties()
 {
     absorption = AbsorptionProperties.Initialize();
     sample     = SampleProperties.Initialize();
     ray        = RayProperties.Initialize();
     detector   = DetectorProperties.Initialize();
     angle      = AngleProperties.Initialize();
 }
Ejemplo n.º 3
0
 public Properties(AbsorptionProperties absorptionProperties, AngleProperties angleProperties,
                   DetectorProperties detectorProperties, RayProperties rayProperties, SampleProperties sampleProperties)
 {
     absorption = absorptionProperties;
     sample     = sampleProperties;
     ray        = rayProperties;
     detector   = detectorProperties;
     angle      = angleProperties;
 }
Ejemplo n.º 4
0
    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);
    }
Ejemplo n.º 5
0
 private static extern int UMF_SetMarkerStr(ref DetectorProperties props, [MarshalAs(UnmanagedType.LPStr)] string str);
Ejemplo n.º 6
0
 private static extern void UMF_FreeDetector(ref DetectorProperties detector);
Ejemplo n.º 7
0
 private static extern int UMF_CreateDetector(int width, int height, float near, float far, float fov, ref DetectorProperties props);
Ejemplo n.º 8
0
 private static extern void UMF_GetResult(ref DetectorProperties detector, ref DetectorResult result);
Ejemplo n.º 9
0
 private static extern int UMF_Detect(ref DetectorProperties detector, float timeout);
Ejemplo n.º 10
0
 private static extern int UMF_SetFrame(ref DetectorProperties detector, byte[] arr);