I have a function x_gradient() which creates a certain number of threads to carry out an edge detection task using the boost library. The threads each execute a function x_gradient_par() and this is where I'm having trouble.
First, let me show you the block where I'm creating the threads:
Code:
template <typename SrcView, typename DstView>
void x_gradient(const SrcView& src, const DstView& dst, int num_threads) {
std::thread* mythreads = new std::thread[num_threads];
int step = src.height() / num_threads;
typedef typename channel_type<DstView>::type dst_channel_t;
for(int i = 0; i < num_threads; i++){
int start = step * i;
int end = start;
if(i == (num_threads - 1))
end = src.height();
else
end = start + step;
mythreads[i] = std::thread(&x_gradient_par<const SrcView&, const DstView&, const dst_channel_t&>, src, dst, start, end);
}
for(int i = 0; i < num_threads; i++){
mythreads[i].join();
}
}
This is what the thread function,x_gradient_par(), looks like:
Code:
template <typename SrcView, typename DstView, typename dst_channel_t>
void x_gradient_par(const SrcView& src, const DstView& dst, int start, int end) {
for (int y = start; y < end; ++y)
{
typename SrcView::x_iterator src_it = src.row_begin(y); //error
typename DstView::x_iterator dst_it = dst.row_begin(y); //error
for (int x = 1; x < src.width() - 1; ++x)
{
static_transform(src_it[x - 1], src_it[x + 1], dst_it[x],
halfdiff_cast_channels<dst_channel_t>());
}
}
}
When I compile, the error I receive is on lines
Code:
typename SrcView::x_iterator src_it = src.row_begin(y);
and
Code:
typename DstView::x_iterator dst_it = dst.row_begin(y);
and it looks something like this:
const boost::gil::image_view<boost::........is not a class, struct, or union type
The dots are there because the error is a lot of gibberish before it gets to the important part.
I'm thinking it must have something to do with the way I'm passing src and dst to the thread function.
Any ideas?
I've attached a log file with the full error and the header file with the code.
Thanks in advance!
log.txt
x_gradient_par.h