示例#1
0
文件: DataType.cs 项目: lee1431/uno
        protected DataType(Source src, Namescope parent, string comment, Modifiers modifiers, string name)
            : base(src, parent, name)
        {
            DocComment = comment;
            Modifiers  = modifiers;
            Interfaces = InterfaceTypes.Empty;
            Attributes = AttributeList.Empty;
            SourceFiles.Add(src.FullPath);

            if (!IsGenericParameter && parent is DataType &&
                (parent as DataType).IsFlattenedDefinition)
            {
                var parentParams = (parent as DataType).FlattenedParameters;
                _flattenedParameters = new GenericParameterType[parentParams.Length];

                for (int i = 0; i < _flattenedParameters.Length; i++)
                {
                    _flattenedParameters[i] = parentParams[i];
                }
            }

            if (IsIntrinsic)
            {
                Intrinsics.TryGetValue(QualifiedName, out BuiltinType);
            }
        }
示例#2
0
        static float[] ProjectPointToPixel(Intrinsics intrin, float[] point)
        {
            float[] pixel = new float[2];
            //assert(intrin->model != RS2_DISTORTION_INVERSE_BROWN_CONRADY); // Cannot project to an inverse-distorted image

            float x = point[0] / point[2], y = point[1] / point[2];

            if (intrin.model == Distortion.ModifiedBrownConrady)
            {
                float r2 = x * x + y * y;
                float f  = 1 + intrin.coeffs[0] * r2 + intrin.coeffs[1] * r2 * r2 + intrin.coeffs[4] * r2 * r2 * r2;
                x *= f;
                y *= f;
                float dx = x + 2 * intrin.coeffs[2] * x * y + intrin.coeffs[3] * (r2 + 2 * x * x);
                float dy = y + 2 * intrin.coeffs[3] * x * y + intrin.coeffs[2] * (r2 + 2 * y * y);
                x = dx;
                y = dy;
            }
            if (intrin.model == Distortion.Ftheta)
            {
                float r  = (float)Math.Sqrt(x * x + y * y);
                float rd = (float)(1.0f / intrin.coeffs[0] * Math.Atan((2 * r * Math.Tan(intrin.coeffs[0] / 2.0f))));
                x *= rd / r;
                y *= rd / r;
            }

            pixel[0] = x * intrin.fx + intrin.ppx;
            pixel[1] = y * intrin.fy + intrin.ppy;
            return(pixel);
        }
示例#3
0
 private TypedArrayInstance(
     Engine engine,
     Intrinsics intrinsics) : base(engine)
 {
     _intrinsics        = intrinsics;
     _viewedArrayBuffer = new ArrayBufferInstance(engine, 0);
 }
        private void StartProcessingBlock(Action <VideoFrame> depth, Action <VideoFrame> color)
        {
            processingBlock.Start(f =>
            {
                using (var frames = FrameSet.FromFrame(f))
                {
                    VideoFrame colorFrame     = frames.ColorFrame.DisposeWith(frames);
                    Intrinsics depthintr      = (pp.GetStream(Stream.Depth).As <VideoStreamProfile>()).GetIntrinsics();
                    DepthFrame depthFrame     = frames.DepthFrame.DisposeWith(frames);
                    VideoFrame colorizedDepth = colorizer.Process <VideoFrame>(depthFrame).DisposeWith(frames);

                    Dispatcher.Invoke(DispatcherPriority.Render, depth, colorizedDepth);
                    Dispatcher.Invoke(DispatcherPriority.Render, color, colorFrame);
                }
            });

            Task.Factory.StartNew(() =>
            {
                while (true)
                {
                    using (var frames = pipeline.WaitForFrames())
                    {
                        // Invoke custom processing block
                        processingBlock.Process(frames);
                    }
                }
            });
        }
示例#5
0
    public static unsafe int test_0_stobj()
    {
        byte *ptr = stackalloc byte [20];

        Intrinsics.UnalignedStobj <short> (ptr + 0, 0x6688);
        if (ptr [0] != 0x88 || ptr [1] != 0x66)
        {
            return(1);
        }

        Intrinsics.UnalignedStobj <short> (ptr + 1, 0x6589);
        if (ptr [1] != 0x89 || ptr [2] != 0x65)
        {
            return(2);
        }

        Intrinsics.UnalignedStobj <int> (ptr + 1, 0x60708090);
        if (ptr [1] != 0x90 || ptr [2] != 0x80 || ptr [3] != 0x70 || ptr [4] != 0x60)
        {
            return(3);
        }

        Intrinsics.UnalignedStobj <long> (ptr + 1, 0x405060708090);
        if (ptr [1] != 0x90 || ptr [2] != 0x80 || ptr [3] != 0x70 || ptr [4] != 0x60 || ptr [5] != 0x50 || ptr [6] != 0x40)
        {
            return(4);
        }

        return(0);
    }
示例#6
0
        /// <summary>
        /// Creates a call instruction to the given method with the given arguments.
        /// </summary>
        /// <param name="method">The target method to invoke.</param>
        /// <param name="arguments">The call arguments.</param>
        private void CreateCall(
            MethodBase method,
            ImmutableArray <ValueReference> arguments)
        {
            var intrinsicContext = new InvocationContext(
                this,
                Location,
                Block,
                Method,
                method,
                arguments);

            // Check for internal remappings first
            RemappedIntrinsics.RemapIntrinsic(ref intrinsicContext);

            // Early rejection for runtime-dependent methods
            VerifyNotRuntimeMethod(intrinsicContext.Method);

            // Handle device functions
            if (!Intrinsics.HandleIntrinsic(intrinsicContext, out var result))
            {
                var targetFunction = DeclareMethod(intrinsicContext.Method);

                result = Builder.CreateCall(
                    Location,
                    targetFunction,
                    intrinsicContext.Arguments);
            }

            // Setup result
            if (result.IsValid && !result.Type.IsVoidType)
            {
                Block.Push(result);
            }
        }
 public Camera(Intrinsics intrinsics, int width, int height, float metricRadius)
 {
     Intrinsics   = intrinsics;
     Width        = width;
     Height       = height;
     MetricRadius = metricRadius;
 }
示例#8
0
        private void projectPixelToPoint(ref Vector3 o_Point, Intrinsics i_Intrin, float[] i_Pixel, float depth)
        {
            float x = (i_Pixel[0] - i_Intrin.Ppx) / i_Intrin.Fx;
            float y = (i_Pixel[1] - i_Intrin.Ppy) / i_Intrin.Fy;

            if (i_Intrin.Model == Distortion.InverseBrownConrady)
            {
                float r2 = (x * x) + (y * y);
                float f  = 1 + (i_Intrin.Coeffs[0] * r2) + (i_Intrin.Coeffs[1] * r2 * r2) + (i_Intrin.Coeffs[4] * r2 * r2 * r2);
                float ux = (x * f) + (2 * i_Intrin.Coeffs[2] * x * y) + (i_Intrin.Coeffs[3] * (r2 + (2 * x * x)));
                float uy = (y * f) + (2 * i_Intrin.Coeffs[3] * x * y) + (i_Intrin.Coeffs[2] * (r2 + (2 * y * y)));
                x = ux;
                y = uy;
            }

            if (i_Intrin.Model == Distortion.Ftheta)
            {
                float rd = (float)Math.Sqrt((x * x) + (y * y));

                if (rd < FLT_EPSILON)
                {
                    rd = FLT_EPSILON;
                }

                float r = (float)Math.Tan((i_Intrin.Coeffs[0] * rd) / Math.Atan(2 * Math.Tan(i_Intrin.Coeffs[0] / 2.0f)));

                x *= r / rd;
                y *= r / rd;
            }

            o_Point.X = depth * x;
            o_Point.Y = depth * y;
            o_Point.Z = depth;
        }
示例#9
0
        public static long UInt64Remainder(long dividend, long divisor)
        {
            //From google-guava
            if (divisor < 0)    // i.e., divisor >= 2^63
            {
                if (compare(dividend, divisor) < 0)
                {
                    return(dividend);   // dividend < divisor
                }
                else
                {
                    return(dividend - divisor);   // dividend >= divisor
                }
            }

            // Optimization - use signed modulus if dividend < 2^63
            if (dividend >= 0)
            {
                return(dividend % divisor);
            }

            /*
             * Otherwise, approximate the quotient, check, and correct if necessary. Our approximation is
             * guaranteed to be either exact or one less than the correct value. This follows from fact
             * that floor(floor(x)/i) == floor(x/i) for any real x and integer i != 0. The proof is not
             * quite trivial.
             */
            long quotiend = (Intrinsics.lushr(dividend, 1) / divisor) << 1;
            long rem      = dividend - quotiend * divisor;

            return(rem - (compare(rem, divisor) >= 0 ? divisor : 0L));
        }
示例#10
0
 public static string Substring(string self, int startIndex, int length)
 {
     if (startIndex < 0)
     {
         throw new ArgumentOutOfRangeException("startIndex");
     }
     if (startIndex > self.Length)
     {
         throw new ArgumentOutOfRangeException("startIndex");
     }
     if (length < 0)
     {
         throw new ArgumentOutOfRangeException("length");
     }
     if (startIndex > self.Length - length)
     {
         throw new ArgumentOutOfRangeException("length");
     }
     if (length == 0)
     {
         return(string.Empty);
     }
     if ((startIndex == 0) && (length == self.Length))
     {
         return(self);
     }
     return(Intrinsics.ToJavaString(self).substring(startIndex, startIndex + length));
 }
示例#11
0
 public static bool RequiresReflectionMethodBodyScannerForCallSite(FlowAnnotations flowAnnotations, MethodDesc methodDefinition)
 {
     return(Intrinsics.GetIntrinsicIdForMethod(methodDefinition) > IntrinsicId.RequiresReflectionBodyScanner_Sentinel ||
            flowAnnotations.RequiresDataflowAnalysis(methodDefinition) ||
            methodDefinition.DoesMethodRequire(DiagnosticUtilities.RequiresUnreferencedCodeAttribute, out _) ||
            methodDefinition.DoesMethodRequire(DiagnosticUtilities.RequiresDynamicCodeAttribute, out _) ||
            methodDefinition.IsPInvoke);
 }
示例#12
0
 public static int Compare(string strA, string strB, bool ignoreCase)
 {
     if (ignoreCase)
     {
         return(Intrinsics.ToJavaString(strA).compareToIgnoreCase(strB));
     }
     return(Intrinsics.ToJavaString(strA).compareTo(strB));
 }
        private void Init()
        {
            using Context ctx = new Context();
            var devices = ctx.QueryDevices();

            Console.WriteLine($"Found {devices.Count} RealSense devices connected.");
            if (devices.Count == 0)
            {
                throw new Exception("No RealSense device detected!");
            }

            Device dev = devices[0];

            Console.WriteLine($"Using device 0: {dev.Info[CameraInfo.Name]}");
            Console.WriteLine("Device Sources:");

            foreach (Sensor sensor in dev.Sensors)
            {
                Console.WriteLine($"Sensor found: {sensor.Info[CameraInfo.Name]}");
            }
            var cfg = new Config();

            cfg.EnableStream(Stream.Depth);
            cfg.EnableStream(Stream.Color, Format.Bgr8);

            intelPipe = new Intel.RealSense.Pipeline();
            PipelineProfile profileIntelPipe = intelPipe.Start(cfg);
            var             streamDepth      = profileIntelPipe.GetStream <VideoStreamProfile>(Stream.Depth);

            sicsDepth = streamDepth.GetIntrinsics();
            Console.WriteLine($"Depth Stream: {sicsDepth.width}X{sicsDepth.height}");

            var streamRBG = profileIntelPipe.GetStream <VideoStreamProfile>(Stream.Color);

            sicsRBG = streamRBG.GetIntrinsics();
            Console.WriteLine($"RBG Stream: {sicsRBG.width}X{sicsRBG.height}");

            Task.Run(() =>
            {
                while (true)
                {
                    try
                    {
                        using FrameSet frames = intelPipe.WaitForFrames();
                        using Frame frDepth   = frames.FirstOrDefault(Stream.Depth);
                        qDepth.Enqueue(frDepth);
                        using Frame frRBG = frames.FirstOrDefault(Stream.Color);
                        qRBG.Enqueue(frRBG);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                    }
                }
            });
        }
        protected override bool ReportSpecialIncompatibleMembersDiagnostic(OperationAnalysisContext operationContext, ImmutableArray <ISymbol> specialIncompatibleMembers, ISymbol member)
        {
            // Some RUC-annotated APIs are intrinsically handled by the trimmer
            if (member is IMethodSymbol method && Intrinsics.GetIntrinsicIdForMethod(new MethodProxy(method)) != IntrinsicId.None)
            {
                return(true);
            }

            return(false);
        }
示例#15
0
        private ClusterMemberId(SocketAddress address)
        {
            var hash = Intrinsics.GetHashCode64(SocketAddressByteGetter64, address.Size, address, false);

            Intrinsics.Bitcast(in hash, out this.address);

            port   = Intrinsics.GetHashCode32(SocketAddressByteGetter32, address.Size, address, false);
            family = (int)address.Family;
            length = address.Size;
        }
 /// <summary>
 /// Creates a new coordinate mapper with the specified intrinsics and extrinsics parameters.
 /// </summary>
 /// <param name="colorIntrinsics">The color intrinsics.</param>
 /// <param name="colorExtrinsics">The color extrinsics.</param>
 /// <param name="depthIntrinsics">The depth intrinsics.</param>
 /// <param name="depthExtrinsics">The depth extrinsics.</param>
 /// <returns>The coordinate mapper with the given intrinsics and extrinsics.</returns>
 public static CoordinateMapper Create(Intrinsics colorIntrinsics, Extrinsics colorExtrinsics, Intrinsics depthIntrinsics, Extrinsics depthExtrinsics)
 {
     return(new CoordinateMapper
            (
                colorIntrinsics,
                colorExtrinsics,
                depthIntrinsics,
                depthExtrinsics
            ));
 }
示例#17
0
    public static unsafe int test_0_cpblk()
    {
        byte *dest = stackalloc byte [20];
        byte *src  = stackalloc byte [20];

        for (int i = 0; i < 20; ++i)
        {
            src [i] = (byte)i;
        }


        Intrinsics.UnalignedCpblk(dest + 0, src + 0, 2);
        if (dest [0] != src [0] || dest [1] != src [1])
        {
            return(1);
        }

        Intrinsics.UnalignedCpblk(dest + 1, src + 0, 2);
        if (dest [1] != src [0] || dest [2] != src [1])
        {
            return(2);
        }

        Intrinsics.UnalignedCpblk(dest + 0, src + 1, 2);
        if (dest [0] != src [1] || dest [1] != src [2])
        {
            return(3);
        }

        Intrinsics.UnalignedCpblk(dest + 1, src + 1, 2);
        if (dest [1] != src [1] || dest [2] != src [2])
        {
            return(3);
        }

        Intrinsics.UnalignedCpblk(dest + 1, src + 1, 4);
        for (int i = 0; i < 4; ++i)
        {
            if (dest [i + 1] != src [i + 1])
            {
                return(4);
            }
        }

        Intrinsics.UnalignedCpblk(dest + 1, src + 1, 8);
        for (int i = 0; i < 8; ++i)
        {
            if (dest [i + 1] != src [i + 1])
            {
                return(5);
            }
        }

        return(0);
    }
示例#18
0
        /// <summary>
        /// 開啟RealSense相機並進行取像
        /// </summary>
        internal void Open(out Image <Bgr, byte> ColorImg,
                           out Image <Rgb, byte> DepthImg,
                           out Image <Rgb, byte> FilteredImg,
                           out VideoFrame color,
                           out DepthFrame depth,
                           out Frame filtered)
        {
            DepthImg = null; ColorImg = null; FilteredImg = null; color = null; depth = null; filtered = null;
            if (CamState != CameraState.Opened)
            {
                PipelineProfile = Camera.Start(cfg);                                                            // 以cfg設定並開始串流
                vsp             = PipelineProfile.GetStream <VideoStreamProfile>(Intel.RealSense.Stream.Depth); // 取得內部參數
                intrinsics      = vsp.GetIntrinsics();
                sp         = PipelineProfile.GetStream(Intel.RealSense.Stream.Color);                           // 取得外部參數
                extrinsics = vsp.GetExtrinsicsTo(sp);
                CamState   = CameraState.Opened;                                                                // 更新相機狀態
            }
            else
            {
                try
                {
                    FrameSet frames = Camera.WaitForFrames();
                    depth    = frames.DepthFrame.DisposeWith(frames);
                    color    = frames.ColorFrame.DisposeWith(frames);
                    filtered = depth;
                    if (depth != null)
                    {
                        //Thres_Filter.Options[Option.MinDistance].Value = float.Parse(form1.textBox2.Text);
                        //Thres_Filter.Options[Option.MaxDistance].Value = float.Parse(form1.textBox1.Text);
                        //filtered = Thres_Filter.Process(filtered);

                        //Spa_Filter.Options[Option.FilterMagnitude].Value = 1;
                        //Spa_Filter.Options[Option.FilterSmoothAlpha].Value = 0.6f;
                        //Spa_Filter.Options[Option.FilterSmoothDelta].Value = 8;
                        //filtered = Spa_Filter.Process(filtered);

                        Temp_Filter.Options[Option.FilterSmoothAlpha].Value = 0.5f;
                        Temp_Filter.Options[Option.FilterSmoothDelta].Value = 20;
                        Temp_Filter.Options[Option.HolesFill].Value         = 2;
                        filtered = Temp_Filter.Process(filtered);

                        depColor      = colorizer.Colorize(depth);
                        filteredColor = colorizer.Colorize(filtered);

                        ColorImg    = new Image <Bgr, byte>(color.Width, color.Height, color.Stride, color.Data);
                        DepthImg    = new Image <Rgb, byte>(depColor.Width, depColor.Height, depColor.Stride, depColor.Data);
                        FilteredImg = new Image <Rgb, byte>(filteredColor.Width, filteredColor.Height, filteredColor.Stride, filteredColor.Data);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
示例#19
0
        public CameraCalibrationResult(int _width, int _height, Extrinsics __extrinsics, Intrinsics __intrinsics, Distortion __distortion, double _error)
        {
            width  = _width;
            height = _height;

            this._extrinsics = __extrinsics;
            this._intrinsics = __intrinsics;
            this._distortion = __distortion;

            error = _error;
        }
示例#20
0
        public TypedReference GetNextArg()
        {
            if (current >= arglist.Length)
            {
                throw new InvalidOperationException(Local.GetText("An attempt was made to read beyond the end of the list."));
            }
            TypedReference result = new TypedReference(Intrinsics.CreatePointerToArray(arglist, current), Intrinsics.GetClass(typeof(object)));

            current++;
            return(result);
        }
示例#21
0
        /// <summary>
        /// Concatenates the array with the specified span of elements.
        /// </summary>
        /// <typeparam name="T">The type of elements in the array.</typeparam>
        /// <param name="left">The array to concatenate.</param>
        /// <param name="right">The tail of concatenation.</param>
        /// <param name="startIndex">The starting index in <paramref name="left"/> at which <paramref name="right"/> should be inserted.</param>
        /// <returns>The array representing all elements from <paramref name="left"/> up to <paramref name="startIndex"/> exclusively including elements from <paramref name="right"/>.</returns>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="startIndex"/> is less than 0 or greater than length of <paramref name="left"/> array.</exception>
        public static T[] Concat <T>(this T[] left, T[] right, long startIndex)
        {
            if (startIndex < 0 || startIndex > Intrinsics.GetLength(left))
            {
                throw new ArgumentOutOfRangeException(nameof(startIndex));
            }
            var result = new T[startIndex + right.LongLength];

            Array.Copy(left, result, startIndex);
            Array.Copy(right, 0L, result, startIndex, right.Length);
            return(result);
        }
示例#22
0
 public static int CompareTo(string self, object value)
 {
     if (value == null)
     {
         return(1);
     }
     if (!(value is string))
     {
         throw new ArgumentException(Local.GetText("value must be string"));
     }
     return(Intrinsics.ToJavaString(self).compareTo((string)value));
 }
示例#23
0
 public static string Concat(object arg0, object arg1)
 {
     if (arg0 == null)
     {
         arg0 = string.Empty;
     }
     if (arg1 == null)
     {
         arg1 = string.Empty;
     }
     return(Intrinsics.ToJavaString(arg0.ToString()).concat(arg0.ToString()));
 }
示例#24
0
文件: Block.cs 项目: adamreeve/ILGPU
        /// <summary>
        /// Pops the required arguments from the stack.
        /// </summary>
        /// <param name="location">The current location.</param>
        /// <param name="methodBase">The method to use for the argument types.</param>
        /// <param name="instanceValue">The instance value (if available).</param>
        public ImmutableArray <ValueReference> PopMethodArgs(
            Location location,
            MethodBase methodBase,
            Value instanceValue)
        {
            var parameters      = methodBase.GetParameters();
            var parameterOffset = methodBase.GetParameterOffset();
            var result          = ImmutableArray.CreateBuilder <ValueReference>(
                parameters.Length + parameterOffset);

            // Handle main params
            for (int i = parameters.Length - 1; i >= 0; --i)
            {
                var param    = parameters[i];
                var argument = Pop(
                    Builder.CreateType(param.ParameterType),
                    param.ParameterType.IsUnsignedInt() ?
                    ConvertFlags.TargetUnsigned : ConvertFlags.None);
                result.Add(argument);
            }

            // Check instance value
            if (parameterOffset > 0)
            {
                if (instanceValue == null)
                {
                    var declaringType = Builder.CreateType(methodBase.DeclaringType);
                    if (!Intrinsics.IsIntrinsicArrayType(methodBase.DeclaringType))
                    {
                        declaringType = Builder.CreatePointerType(
                            declaringType,
                            MemoryAddressSpace.Generic);
                    }
                    instanceValue = Pop(
                        declaringType,
                        ConvertFlags.None);
                }
                else
                {
                    // Wire instance
                    instanceValue = Builder.CreateAddressSpaceCast(
                        location,
                        instanceValue,
                        MemoryAddressSpace.Generic);
                }

                result.Add(instanceValue);
            }

            result.Reverse();
            return(result.MoveToImmutable());
        }
示例#25
0
        private protected unsafe UnmanagedMemory(int length, bool zeroMem)
        {
            var size = SizeOf(length);

            address = Marshal.AllocHGlobal(new IntPtr(size));
            GC.AddMemoryPressure(size);
            Length = length;
            if (zeroMem)
            {
                Intrinsics.ClearBits(address.ToPointer(), size);
            }
            owner = true;
        }
示例#26
0
        /// <summary>
        /// Checks whether the specified value is equal to one
        /// of the specified values.
        /// </summary>
        /// <remarks>
        /// This method uses <see cref="IEquatable{T}.Equals(T)"/>
        /// to check equality between two values.
        /// </remarks>
        /// <typeparam name="T">The type of object to compare.</typeparam>
        /// <param name="value">The value to compare with other.</param>
        /// <param name="values">Candidate objects.</param>
        /// <returns><see langword="true"/>, if <paramref name="value"/> is equal to one of <paramref name="values"/>.</returns>
        public static bool IsOneOf <T>(this T value, params T[] values)
            where T : struct, IEquatable <T>
        {
            for (nint i = 0; i < Intrinsics.GetLength(values); i++)
            {
                if (values[i].Equals(value))
                {
                    return(true);
                }
            }

            return(false);
        }
示例#27
0
        /// <summary>
        /// Checks whether the specified object is equal to one
        /// of the specified objects.
        /// </summary>
        /// <remarks>
        /// This method uses <see cref="object.Equals(object, object)"/>
        /// to check equality between two objects.
        /// </remarks>
        /// <typeparam name="T">The type of object to compare.</typeparam>
        /// <param name="value">The object to compare with other.</param>
        /// <param name="values">Candidate objects.</param>
        /// <returns><see langword="true"/>, if <paramref name="value"/> is equal to one of <paramref name="values"/>.</returns>
        public static bool IsOneOf <T>(this T value, params T?[] values)
            where T : class
        {
            for (nint i = 0; i < Intrinsics.GetLength(values); i++)
            {
                if (Equals(values[i], value))
                {
                    return(true);
                }
            }

            return(false);
        }
示例#28
0
        internal TypedArrayInstance(
            Engine engine,
            Intrinsics intrinsics,
            TypedArrayElementType type,
            uint length) : this(engine, intrinsics)
        {
            _arrayElementType = type;
            _arrayLength      = length;

            _contentType = type != TypedArrayElementType.BigInt64 && type != TypedArrayElementType.BigUint64
                ? TypedArrayContentType.Number
                : TypedArrayContentType.BigInt;
        }
示例#29
0
        public static string Concat(string str0, string str1)
        {
            if (str0 == null)
            {
                str0 = string.Empty;
            }
            if (str1 == null)
            {
                str1 = string.Empty;
            }

            return(Intrinsics.ToJavaString(str0).concat(str1));
        }
示例#30
0
        private static bool ValidComputer(Intrinsics flags = Intrinsics.None)
        {
            if (!RemoteExecutor.IsSupported)
            {
                return(false);
            }

            if (flags == Intrinsics.None)
            {
                return(true);
            }

            // I realize we could do a bitwise AND operation here, but this isn't really written for performance.
            if (flags.HasFlag(Intrinsics.Sse) && !Sse.IsSupported)
            {
                return(false);
            }

            if (flags.HasFlag(Intrinsics.Sse2) && !Sse2.IsSupported)
            {
                return(false);
            }

            if (flags.HasFlag(Intrinsics.Sse3) && !Sse3.IsSupported)
            {
                return(false);
            }

            if (flags.HasFlag(Intrinsics.Avx) && !Avx.IsSupported)
            {
                return(false);
            }

            if (flags.HasFlag(Intrinsics.Avx2) && !Avx2.IsSupported)
            {
                return(false);
            }

            if (flags.HasFlag(Intrinsics.AdvSimd) && !AdvSimd.IsSupported)
            {
                return(false);
            }

            if (flags.HasFlag(Intrinsics.AdvSimdArm64) && !AdvSimd.IsSupported)
            {
                return(false);
            }

            return(true);
        }
示例#31
0
        public Camera(string name, string uuid, Size imageSize, PointF principalPointEstimate, double focalLength, double nearPlaneDistance, double farPlaneDistance, int numRadialDistortionCoefficients)
        {
            PathToIntrinsics = GetPathToIntrinsics(name, uuid);
            Name = name;
            Uuid = uuid;
            NumRadialDistortionCoefficients = numRadialDistortionCoefficients;

            World = Matrix.Identity;
            View = Matrix.Identity;

            if (!String.IsNullOrWhiteSpace(PathToIntrinsics))
                if (File.Exists(PathToIntrinsics))
                    using (var fs = File.OpenRead(PathToIntrinsics))
                        Intrinsics = new Intrinsics(imageSize, nearPlaneDistance, farPlaneDistance, fs);
            
            if (Intrinsics == null)
                Intrinsics = new Intrinsics(imageSize, principalPointEstimate, focalLength, nearPlaneDistance, farPlaneDistance, numRadialDistortionCoefficients);

            Frustum = new Frustum(imageSize, this);
            Text = new Text(Name, World.Translation, Color.Black);
        }
示例#32
0
		//called when data for any output pin is requested
		public void Evaluate(int SpreadMax)
		{
			if (FPinInDo[0])
			{
				int nPointsPerImage = FPinInObject.SliceCount;
				bool useVVVVCoords = FPinInCoordSystem[0] == TCoordinateSystem.VVVV;

				if (nPointsPerImage == 0)
				{
					FStatus[0] = "Insufficient points";
					return;
				}
				int nImages = FPinInImage.SliceCount / nPointsPerImage;

				MCvPoint3D32f[][] objectPoints = new MCvPoint3D32f[nImages][];
				PointF[][] imagePoints = new PointF[nImages][];
				Size imageSize = new Size( (int) FPinInSensorSize[0].x, (int) FPinInSensorSize[0].y);
				CALIB_TYPE flags = new CALIB_TYPE();
				IntrinsicCameraParameters intrinsicParam = new IntrinsicCameraParameters();
				ExtrinsicCameraParameters[] extrinsicsPerView;
				GetFlags(out flags);

				if (flags.HasFlag(CALIB_TYPE.CV_CALIB_USE_INTRINSIC_GUESS))
				{
					if (FPinInIntrinsics[0] == null)
					{
						Matrix<double> mat = intrinsicParam.IntrinsicMatrix;
						mat[0, 0] = FPinInSensorSize[0].x / 2.0d;
						mat[1, 1] = FPinInSensorSize[0].y / 2.0d;
						mat[0, 2] = FPinInSensorSize[0].x / 2.0d;
						mat[1, 2] = FPinInSensorSize[0].y / 2.0d;
						mat[2, 2] = 1;
					}
					else
					{
						intrinsicParam.DistortionCoeffs = FPinInIntrinsics[0].intrinsics.DistortionCoeffs.Clone();
						intrinsicParam.IntrinsicMatrix = FPinInIntrinsics[0].intrinsics.IntrinsicMatrix.Clone();
					}

				}

				imagePoints = MatrixUtils.ImagePoints(FPinInImage, nPointsPerImage);

				for (int i=0; i<nImages; i++)
				{
					objectPoints[i] = MatrixUtils.ObjectPoints(FPinInObject, useVVVVCoords);
				}

				try
				{
					FPinOutError[0] = CameraCalibration.CalibrateCamera(objectPoints, imagePoints, imageSize, intrinsicParam, flags, out extrinsicsPerView);

					Intrinsics intrinsics = new Intrinsics(intrinsicParam, imageSize);
					FPinOutIntrinsics[0] = intrinsics;
					if (useVVVVCoords)
						FPinOutProjection[0] = intrinsics.Matrix;
					else
						FPinOutProjection[0] = intrinsics.Matrix;

					FPinOutExtrinsics.SliceCount = nImages;
					FPinOutView.SliceCount = nImages;
					for (int i = 0; i < nImages; i++)
					{
						Extrinsics extrinsics = new Extrinsics(extrinsicsPerView[i]);
						FPinOutExtrinsics[i] = extrinsics;

						if (useVVVVCoords)
							FPinOutView[i] = MatrixUtils.ConvertToVVVV(extrinsics.Matrix);
						else
							FPinOutView[i] = extrinsics.Matrix;
					}

					FPinOutSuccess[0] = true;
					FStatus[0] = "OK";
				}
				catch (Exception e)  {
					FPinOutSuccess[0] = false;
					FStatus[0] = e.Message;
				}
			}

		}