Skip to content

[BUG] Invalid convert color code: 48 #213

Open
@Strinkin

Description

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。

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working as expected (software, install, documentation)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions