public void SetReferenceImage(NPPImage_32fC1 reference) { NppiRect saveRoi = new NppiRect(reference.PointRoi, reference.SizeRoi); NppiRect roi = new NppiRect(); roi.x = 0; // (reference.WidthRoi - imgToTrackRotated.WidthRoi) / 2; roi.y = 0; // (reference.HeightRoi - imgToTrackRotated.HeightRoi) / 2; roi.width = imgToTrackRotated.WidthRoi; roi.height = imgToTrackRotated.HeightRoi; reference.SetRoi(roi); reference.Copy(imgToTrackRotated); forward.Exec(imgToTrackRotated.DevicePointerRoi, imgRefCplx.DevicePointer); reference.SetRoi(saveRoi); }
public void LucasKanade(NPPImage_32fC1 sourceImg, NPPImage_32fC1 targetImg, NPPImage_32fC2 tiledFlow, int tileSize, int tileCountX, int tileCountY, int iterations, float2 baseShift, float baseRotation, float minDet, int windowSize) { createFlowFieldFromTiles.RunSafe(tiledFlow, d_flow, baseShift, baseRotation, tileSize, tileCountX, tileCountY); for (int iter = 0; iter < iterations; iter++) { warpingKernel.RunSafe(sourceImg, d_tmp, d_flow); NppiPoint p = new NppiPoint(0, 0); d_Ix.Set(0); d_Iy.Set(0); d_Iz.Set(0); computeDerivativesKernel.RunSafe(d_tmp, targetImg, d_Ix, d_Iy, d_Iz); lukasKanade.RunSafe(d_flow, d_Ix, d_Iy, d_Iz, minDet, windowSize); } warpingKernel.RunSafe(sourceImg, d_tmp, d_flow); d_tmp.Copy(sourceImg); }
public void RunImage(NPPImage_32fC3 input, NPPImage_32fC3 output) { NppiRect roiOrig = new NppiRect(input.PointRoi, input.SizeRoi); output.Set(new float[] { 0, 0, 0 }); IEnumerable <Tiler.RoiInputOutput> rois = Tiler.GetROIs(new NppiRect(new NppiPoint(8, 8), new NppiSize(input.WidthRoi - 16, input.HeightRoi - 16)), _tileSize, 8); foreach (var item in rois) { input.SetRoi(item.inputROI); output.SetRoi(item.positionInFinalImage); tile.ResetRoi(); input.Copy(tile); NPPImage_32fC1 npp32fCR = new NPPImage_32fC1(tileAsPlanes.DevicePointer, _tileSize, _tileSize, _tileSize * sizeof(float)); NPPImage_32fC1 npp32fCG = new NPPImage_32fC1(tileAsPlanes.DevicePointer + (_tileSize * _tileSize * sizeof(float)), _tileSize, _tileSize, _tileSize * sizeof(float)); NPPImage_32fC1 npp32fCB = new NPPImage_32fC1(tileAsPlanes.DevicePointer + 2 * (_tileSize * _tileSize * sizeof(float)), _tileSize, _tileSize, _tileSize * sizeof(float)); tile.Copy(npp32fCR, 0); tile.Copy(npp32fCG, 1); tile.Copy(npp32fCB, 2); start.Inference(tileAsPlanes); CudaDeviceVariable <float> res = final.GetResult(); int size = _tileSize - 16; npp32fCR = new NPPImage_32fC1(res.DevicePointer, size, size, size * sizeof(float)); npp32fCG = new NPPImage_32fC1(res.DevicePointer + (size * size * sizeof(float)), size, size, size * sizeof(float)); npp32fCB = new NPPImage_32fC1(res.DevicePointer + 2 * (size * size * sizeof(float)), size, size, size * sizeof(float)); tile.SetRoi(0, 0, _tileSize - 16, _tileSize - 16); npp32fCR.Copy(tile, 0); npp32fCG.Copy(tile, 1); npp32fCB.Copy(tile, 2); tile.SetRoi(item.outputROI); tile.Copy(output); } input.SetRoi(roiOrig); output.SetRoi(roiOrig); }