Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Invalid convert color code: 48 #213

Open
Strinkin opened this issue Oct 18, 2024 · 0 comments
Open

[BUG] Invalid convert color code: 48 #213

Strinkin opened this issue Oct 18, 2024 · 0 comments
Labels
bug Something isn't working as expected (software, install, documentation)

Comments

@Strinkin
Copy link

Describe the bug
my code are follow:
// ######################### begin #########################
int main(int argc, char** argv) {
cudaStream_t stream;
cudaStreamCreate(&stream);

int in_width = 1440;
int in_height = 1080;
int in_channels = 1;
int batch_size = 1;

int nCurValue = in_width * in_height * in_channels;
unsigned char* pData = (unsigned char*)malloc(sizeof(unsigned char) * nCurValue);

std::ifstream infile("/home/strinkin/Pictures/a.raw", std::ios::binary);
infile.read(reinterpret_cast<char*>(pData), nCurValue);

nvcv::Tensor inTensor(batch_size, {in_width, in_height}, nvcv::FMT_Y8_ER);

auto in_data = inTensor.exportData<nvcv::TensorDataStridedCuda>();
cudaMemcpyAsync(in_data->basePtr(), pData, sizeof(uint8_t) * in_width * in_height * in_channels, cudaMemcpyHostToDevice, stream);
cudaStreamSynchronize(stream);

int out_width = 1440;
int out_height = 1080;
int out_channels = 3;

nvcv::Tensor bgrTensor(batch_size, {out_width, out_height}, nvcv::FMT_BGR8);
auto bgr_data = bgrTensor.exportData<nvcv::TensorDataStridedCuda>();

cvcuda::CvtColor cvtOp;
cvtOp(stream, inTensor, bgrTensor, NVCV_COLOR_BayerRG2BGR);

cv::Mat h_image(out_height, out_width, CV_8UC3);

// bgrTensor -> h_image
cudaMemcpyAsync(h_image.ptr(), bgr_data->basePtr(), sizeof(uint8_t) * out_width * out_height * out_channels, cudaMemcpyDeviceToHost, stream);
cudaStreamSynchronize(stream);
cout << h_image << endl;
cout << h_image.rows << " " << h_image.cols << " " << h_image.channels() << endl;

cv::imshow("output", h_image);
cv::waitKey(0); 
cv::destroyAllWindows(); 

cudaStreamDestroy(stream);

}
// ########################## end ############################
// ######################description####################
the function: cvtOp(stream, inTensor, bgrTensor, NVCV_COLOR_BayerRG2BGR);
throw an error:
//############ terrminal output ###################
ERROR: Invalid convert color code: 48
terminate called after throwing an instance of 'nvcv::Exception'
what(): NVCV_ERROR_INVALID_ARGUMENT: :0 (INVALID_PARAMETER)
//############ terrminal output ###################
when i change NVCV_COLOR_BayerRG2BGR to NVCV_COLOR_GRAY2BGR, the error disppear

I'm desperate for a solution,very thankful。

@Strinkin Strinkin added the bug Something isn't working as expected (software, install, documentation) label Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working as expected (software, install, documentation)
Projects
None yet
Development

No branches or pull requests

1 participant