Hi,
I’m working on an object detector following the Viola & Jones approach by using Haar cascades.
At the moment, the Haar cascades are implemented as huge arrays containing different structs for stages, classifiers and features.
I use the global memory, upload the structs to the device and give the pointer as parameter to the kernels:
// Host (Upload)
cudaMalloc((void**)&deviceFeatures, sizeof(cudaFeature) * totalFeatures);
cudaMemcpy(deviceFeatures, features, sizeof(cudaFeature) * totalFeatures, cudaMemcpyHostToDevice);
checkCudaError("uploading feature array");
// Device
cudaFeature feature = deviceFeatures + offset;
Due to performance reasons, I’m thinking about using textures for the structs:
texture<cudaFeature, 1, cudaReadModeElementType> featureTexture;
// Host (Upload/Binding)
cudaMalloc((void**)&deviceFeatures, sizeof(cudaFeature) * totalFeatures);
cudaMemcpy(deviceFeatures, features, sizeof(cudaFeature) * totalFeatures, cudaMemcpyHostToDevice);
cudaBindTexture(0, featureTexture, deviceFeatures);
checkCudaError("uploading feature array");
// Device
cudaFeature feature = tex1Dfetch(featureTexture, offset);
Unfortunately, the tex1Dfetch methods only support basic types like int, uchar, float etc… and I got the following compiler error:
Is there any possibility to access structs by using cuda textures?
Maybe my approach is completely wrong and somebody has a better solution for my needs!?
Many thanks in advice,
Daniel