64,654
社区成员
发帖
与我相关
我的任务
分享
#define N 20
struct BModel_Sequential
{
......
/* Storage for the history. */
uint8_t *historyBuffer[N]; //指针数组
};
// Allocates and initializes a C3R model structure
void BModel_Init_8u_C3R(BModel_Sequential_t *model, const Mat& img, const uint32_t width, const uint32_t height)
{
/* Creates the historyImage structure. */
model->historyBuffer[N] = NULL;
model->historyBuffer[N] = (uint8_t*)malloc((5 * width) * height * sizeof(uint8_t));
.........
for (int k = 0; k < N; k++){
for (int i = 0; i < height; i++){
for (int j = 0; j < width; j++){
uint8_t value_B = img.at<Vec3b>(i, j)[0]; //通道B
int value_plus_noise_B = value_B + rand() % 20 - 10;
if (value_plus_noise_B < 0) { value_plus_noise_B = 0; }
......
//下面提示访问冲突???
model->historyBuffer[k][(i*width * 5) + 5 * j] = value_plus_noise_B;
model->historyBuffer[k][(i*width * 5) + 5 * j + 1] = value_plus_noise_G;
model->historyBuffer[k][(i*width * 5) + 5 * j + 2] = value_plus_noise_R;
model->historyBuffer[k][(i*width * 5) + 5 * j + 3] = value_plus_noise_X;
model->historyBuffer[k][(i*width * 5) + 5 * j + 4] = value_plus_noise_Y;
}
}
}
}
BModel_Sequential_t *BModel_Sequential_New() // Creates the data structure
{
.....
model->historyBuffer[N] = NULL;
return(model);
}
int32_t BModel_Sequential_Free(BModel_Sequential_t *model) // Frees the structure
{
.........
free(model->historyBuffer);
return 0;
}