Ejemplo n.º 1
0
        //int width, int height, int stride,
        //cudaTextureObject_t texUV, float* __restrict__ out, cudaTextureObject_t texToWarp
        public float RunSafe(NPPImage_32fC1 inImg, NPPImage_32fC1 outImg, NPPImage_32fC2 flow)
        {
            this.BlockDimensions = new dim3(32, 6, 1);
            this.SetComputeSize((uint)(outImg.WidthRoi), (uint)(outImg.HeightRoi), 1);

            CudaResourceDesc      descImg    = new CudaResourceDesc(inImg);
            CudaTextureDescriptor texDescImg = new CudaTextureDescriptor(CUAddressMode.Mirror, CUFilterMode.Linear, CUTexRefSetFlags.NormalizedCoordinates);
            CudaTexObject         texImg     = new CudaTexObject(descImg, texDescImg);

            CudaResourceDesc      descFlow    = new CudaResourceDesc(flow);
            CudaTextureDescriptor texDescFlow = new CudaTextureDescriptor(CUAddressMode.Clamp, CUFilterMode.Point, CUTexRefSetFlags.NormalizedCoordinates);
            CudaTexObject         texFlow     = new CudaTexObject(descFlow, texDescFlow);

            return(this.Run(outImg.WidthRoi, outImg.HeightRoi, outImg.Pitch, texFlow.TexObject, outImg.DevicePointerRoi, texImg.TexObject));
        }
Ejemplo n.º 2
0
        //float2* __restrict__ outImg,
        //cudaTextureObject_t texObjShiftXY,
        //int imgWidth,
        //int imgHeight,
        //int imgPitch
        public float RunSafe(NPPImage_32fC2 inFlow, NPPImage_32fC2 outFlow, float2 baseShift, float baseRotation, int tileSize, int tileCountX, int tileCountY)
        {
            this.BlockDimensions = new dim3(32, 6, 1);
            this.SetComputeSize((uint)(outFlow.WidthRoi), (uint)(outFlow.HeightRoi), 1);

            CudaResourceDesc      descImg    = new CudaResourceDesc(inFlow);
            CudaTextureDescriptor texDescImg = new CudaTextureDescriptor(CUAddressMode.Clamp, CUFilterMode.Linear, CUTexRefSetFlags.NormalizedCoordinates);
            CudaTexObject         texImg     = new CudaTexObject(descImg, texDescImg);


            float t = this.Run(outFlow.DevicePointerRoi, texImg.TexObject, tileSize, tileCountX, tileCountY, outFlow.WidthRoi, outFlow.HeightRoi, outFlow.Pitch, baseShift, baseRotation);

            texImg.Dispose();
            return(t);
        }
Ejemplo n.º 3
0
        public float RunSafe(NPPImage_32fC1 imgSource, NPPImage_32fC1 Ix, NPPImage_32fC1 Iy)
        {
            this.BlockDimensions = new dim3(32, 6, 1);
            this.SetComputeSize((uint)(imgSource.WidthRoi), (uint)(imgSource.HeightRoi), 1);

            CudaResourceDesc      descImgSource    = new CudaResourceDesc(imgSource);
            CudaTextureDescriptor texDescImgSource = new CudaTextureDescriptor(CUAddressMode.Mirror, CUFilterMode.Linear, CUTexRefSetFlags.NormalizedCoordinates);
            CudaTexObject         texImgSource     = new CudaTexObject(descImgSource, texDescImgSource);


            float t = this.Run(Ix.WidthRoi, Ix.HeightRoi, Ix.Pitch, Ix.DevicePointerRoi, Iy.DevicePointerRoi, texImgSource.TexObject);

            texImgSource.Dispose();

            return(t);
        }
        /*
         *
         * const float3* __restrict__ rawImgRef,
         * const float3* __restrict__ rawImgMoved,
         * float3* __restrict__ robustnessMask,
         * cudaTextureObject_t texUV,
         * int imgWidth,
         * int imgHeight,
         * int imgPitch,
         * float alpha,
         * float beta)
         */
        public float RunSafe(NPPImage_32fC3 rawImgRef, NPPImage_32fC3 rawImgMoved, NPPImage_32fC4 robustnessMask, NPPImage_32fC2 shift, float alpha, float beta, float thresholdM)
        {
            this.BlockDimensions = new dim3(8, 8, 1);
            this.SetComputeSize((uint)(rawImgRef.WidthRoi), (uint)(rawImgRef.HeightRoi), 1);
            this.DynamicSharedMemory = BlockDimensions.x * BlockDimensions.y * float3.SizeOf * 3 * 3;

            CudaResourceDesc      descShift    = new CudaResourceDesc(shift);
            CudaTextureDescriptor texDescShift = new CudaTextureDescriptor(CUAddressMode.Mirror, CUFilterMode.Linear, CUTexRefSetFlags.NormalizedCoordinates);
            CudaTexObject         texShift     = new CudaTexObject(descShift, texDescShift);


            float t = this.Run(rawImgRef.DevicePointerRoi, rawImgMoved.DevicePointerRoi, robustnessMask.DevicePointerRoi, texShift.TexObject, rawImgRef.WidthRoi,
                               rawImgRef.HeightRoi, rawImgRef.Pitch, robustnessMask.Pitch, alpha, beta, thresholdM);

            texShift.Dispose();

            return(t);
        }
Ejemplo n.º 5
0
        public float RunSafe(CudaDeviceVariable <ushort> dataIn, NPPImage_32fC3 imgOut, NPPImage_32fC3 totalWeights, NPPImage_32fC4 certaintyMask, NPPImage_32fC4 kernelParam, NPPImage_32fC2 shifts, float3 whiteLevel, float3 blackLevel)
        {
            SetComputeSize((uint)imgOut.WidthRoi, (uint)imgOut.HeightRoi);

            CudaResourceDesc      descKernel    = new CudaResourceDesc(kernelParam);
            CudaTextureDescriptor texDescKernel = new CudaTextureDescriptor(CUAddressMode.Clamp, CUFilterMode.Linear, CUTexRefSetFlags.NormalizedCoordinates);
            CudaTexObject         texKernel     = new CudaTexObject(descKernel, texDescKernel);

            CudaResourceDesc      descShift    = new CudaResourceDesc(shifts);
            CudaTextureDescriptor texDescShift = new CudaTextureDescriptor(CUAddressMode.Mirror, CUFilterMode.Linear, CUTexRefSetFlags.NormalizedCoordinates);
            CudaTexObject         texShift     = new CudaTexObject(descShift, texDescShift);

            float t = base.Run(dataIn.DevicePointer, imgOut.DevicePointerRoi, totalWeights.DevicePointerRoi,
                               certaintyMask.DevicePointerRoi, texKernel.TexObject, texShift.TexObject,
                               whiteLevel, blackLevel, imgOut.WidthRoi, imgOut.HeightRoi, imgOut.Pitch, certaintyMask.Pitch, kernelParam.Pitch, shifts.Pitch);

            texShift.Dispose();
            texKernel.Dispose();
            return(t);
        }