Ejemplo n.º 1
0
        protected override JobHandle ScheduleAddImageJobImpl(
            NativeSlice <byte> imageBytes,
            Vector2Int sizeInPixels,
            TextureFormat format,
            XRReferenceImage referenceImage,
            JobHandle inputDeps)
        {
            var grayscaleImage = new NativeArray <byte>(
                sizeInPixels.x * sizeInPixels.y,
                Allocator.Persistent,
                NativeArrayOptions.UninitializedMemory);

            var conversionHandle = ConversionJob.Schedule(imageBytes, sizeInPixels, format, grayscaleImage, inputDeps);

            // Add a reference in case we are destroyed while the job is running
            RcoApi.Retain(m_NativePtr);
            return(new AddImageJob
            {
                database = m_NativePtr,
                managedReferenceImage = new ManagedReferenceImage(referenceImage),
                grayscaleImage = grayscaleImage,
                width = sizeInPixels.x,
                height = sizeInPixels.y,
                name = new NativeArray <byte>(Encoding.UTF8.GetBytes(referenceImage.name + "\0"), Allocator.Persistent),
            }.Schedule(conversionHandle));
        }
Ejemplo n.º 2
0
        protected override AddReferenceImageJobState ScheduleAddImageWithValidationJobImpl(NativeSlice <byte> imageBytes,
                                                                                           Vector2Int sizeInPixels, TextureFormat format, XRReferenceImage referenceImage, JobHandle inputDeps)
        {
            var grayscaleImage = new NativeArray <byte>(
                sizeInPixels.x * sizeInPixels.y,
                Allocator.Persistent,
                NativeArrayOptions.UninitializedMemory);

            inputDeps = ConversionJob.Schedule(imageBytes, sizeInPixels, format, grayscaleImage, inputDeps);

            // Add a reference in case we are destroyed while the job is running
            RcoApi.Retain(m_Self);

            var validator = CreateValidator(m_Self);

            inputDeps = new AddImageJob
            {
                database              = m_Self,
                validator             = validator,
                managedReferenceImage = new ManagedReferenceImage(referenceImage),
                grayscaleImage        = grayscaleImage,
                width  = sizeInPixels.x,
                height = sizeInPixels.y,
                name   = GetUTF8Bytes(referenceImage.name),
            }.Schedule(inputDeps);

            return(CreateAddJobState(validator, inputDeps));
        }
Ejemplo n.º 3
0
            public unsafe void Execute()
            {
                AddImage(database, validator, ref managedReferenceImage,
                         grayscaleImage.GetUnsafePtr(), width, height, name.GetUnsafePtr());

                if (!GetStatus(validator).IsSuccess())
                {
                    managedReferenceImage.Dispose();
                }

                RcoApi.Release(database);
            }
Ejemplo n.º 4
0
            public unsafe void Execute()
            {
                bool success = UnityARCore_ImageDatabase_addImage(
                    database,
                    ref managedReferenceImage,
                    grayscaleImage.GetUnsafePtr(),
                    width, height,
                    name.GetUnsafePtr());

                if (!success)
                {
                    managedReferenceImage.Dispose();
                }

                RcoApi.Release(database);
            }