private void btnProcess_Click(object sender, EventArgs e) { this.Enabled = false; // // Initialise the GPU // clRTOCT clrtoct; try { DateTime end; lblStatus.Text = "Initialising GPU..."; Application.DoEvents(); clrtoct = new clRTOCT( (int)nudDeviceIndex.Value, (int)nudInputSpectraLength.Value, (int)nudOutputAScanLength.Value, (int)nudNumBScans.Value, (int)nudNumAScansPerBScan.Value, (int)nudAScanAveragingFactor.Value, (int)nudBScanAveragingFactor.Value, pHostResamplingTable, pHostReferenceSpectrum, pHostReferenceAScan, pKernelPath, 2, 2, "-cl-fast-relaxed-math -cl-mad-enable" ); // // Reformat the input spectra into the correct 2D array // DateTime start = DateTime.Now; // Process lblStatus.Text = "Pre-Processing..."; Application.DoEvents(); clrtoct.PreProcessSpectra(pHostSpectra, clRTOCT.eWINDOW_TYPE.BLACKMAN); // float[,] preProcessed = new float[pHostSpectra.GetLength(0),pHostSpectra.GetLength(1)*2]; // clrtoct.GetPreProcessed(preProcessed); lblStatus.Text = "Fourier transform..."; Application.DoEvents(); clrtoct.InverseFourierTransform(); lblStatus.Text = "Post-processing..."; Application.DoEvents(); clrtoct.PostProcessOCTSignal((float)nudBmpMin.Value,(float)nudBmpMax.Value); lblStatus.Text = "Copying back to host..."; Application.DoEvents(); clrtoct.GetLogEnvelope(pHostLogEnvBScan); this.pictureBox1.Image = clrtoct.getBScanBitmap(1); byte[] bscanBmps = new byte[clrtoct.TotalBScans * clrtoct.BScanBitmapHeight * clrtoct.BScanStride]; clrtoct.GetBScanBitmaps(bscanBmps); end = DateTime.Now; lblStatus.Text = String.Format("Done in {0:0.000} s",end.Subtract(start).TotalSeconds); Application.DoEvents(); clrtoct.Dispose();// = null; // Force the clRTOCT object to dispose } catch (Exception ex) { MessageBox.Show(ex.Message); clrtoct = null; } this.Enabled = true; }
private void btnProcess_Click(object sender, EventArgs e) { this.Enabled = false; // // Initialise the GPU // clRTOCT clrtoct; try { DateTime end; lblStatus.Text = "Initialising GPU..."; Application.DoEvents(); clrtoct = new clRTOCT( (int)nudDeviceIndex.Value, (int)nudInputSpectraLength.Value, (int)nudOutputAScanLength.Value, (int)nudNumBScans.Value, (int)nudNumAScansPerBScan.Value, (int)nudAScanAveragingFactor.Value, (int)nudBScanAveragingFactor.Value, pHostResamplingTable, pHostReferenceSpectrum, pHostReferenceAScan, pKernelPath, 2, 2, "-cl-fast-relaxed-math -cl-mad-enable" ); // // Reformat the input spectra into the correct 2D array // DateTime start = DateTime.Now; // Process lblStatus.Text = "Pre-Processing..."; Application.DoEvents(); clrtoct.PreProcessSpectra(pHostSpectra, clRTOCT.eWINDOW_TYPE.BLACKMAN); // float[,] preProcessed = new float[pHostSpectra.GetLength(0),pHostSpectra.GetLength(1)*2]; // clrtoct.GetPreProcessed(preProcessed); lblStatus.Text = "Fourier transform..."; Application.DoEvents(); clrtoct.InverseFourierTransform(); lblStatus.Text = "Post-processing..."; Application.DoEvents(); clrtoct.PostProcessOCTSignal((float)nudBmpMin.Value, (float)nudBmpMax.Value); lblStatus.Text = "Copying back to host..."; Application.DoEvents(); clrtoct.GetLogEnvelope(pHostLogEnvBScan); this.pictureBox1.Image = clrtoct.getBScanBitmap(1); byte[] bscanBmps = new byte[clrtoct.TotalBScans * clrtoct.BScanBitmapHeight * clrtoct.BScanStride]; clrtoct.GetBScanBitmaps(bscanBmps); end = DateTime.Now; lblStatus.Text = String.Format("Done in {0:0.000} s", end.Subtract(start).TotalSeconds); Application.DoEvents(); clrtoct.Dispose();// = null; // Force the clRTOCT object to dispose } catch (Exception ex) { MessageBox.Show(ex.Message); clrtoct = null; } this.Enabled = true; }