unsigned char* createImageBuffer(unsigned int bytes)
{
unsigned char* ptr;
cudaSetDeviceFlags(cudaDeviceMapHost);
cudaHostAlloc(&ptr, bytes, cudaHostAllocMapped);
return ptr;
}
cv::Mat sGray(frame.size(), CV_8U, createImageBuffer(frame.size().width * frame.size().height));
cv::Mat dGray(frame.size(), CV_8U, createImageBuffer(frame.size().width * frame.size().height));
cv::Mat eGray(frame.size(), CV_8U, createImageBuffer(frame.size().width * frame.size().height));
The problem during debugging is regarding accessing restricted memory at 0x00000000. The function is supposed to return a pointer to the place of image bytes allocation however it gives me the bad ptr value.
Output:
First-chance exception at 0x0c10e473 in improc.exe: 0xC0000005: Access violation reading location 0x00000000. Unhandled exception at 0x0c10e473 in improc.exe: 0xC0000005: Access violation reading location 0x00000000.
The video to the tutorial I followed: https://youtu.be/j9vb5UjQCQg
frame
is not empty? – ilke444createImageBuffer
returned null pointer. And the most possible cause is what @ilke444 indicated -frame.size()
returning 0. – pSoLT