We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I want to apply a smooth to an image,for that purpose I create the function "sum" Here's my code
double sum(cv::Mat img, int startedX, int startedY, int w) {
double res = 0;
std::cout << "startedX= " << startedX << "/ startedY= " << startedY << std::endl;
for (int i = startedX - ((w - 1) / 2); i < startedX + ((w + 1) / 2); i++) {
std::cout << "i= " << i << std::endl;
for (int j = startedY - ((w - 1) / 2) ; j < startedY + ((w + 1) / 2); j++) {
std::cout << " j= " << j << std::endl;
if ((i >= 0 && i < img.size().width) && (j >= 0 && j < img.size().height)) {
res += img.at<float>(i,j);
}
}
}
return res;
}
This is a portion of my main function where the program crashes :
for (int k = 0; k < imgSource.size().width; k++) {
for (int l = 0; l < imgSource.size().height; l++) {
if( (k >= 0 && k < imgSource.size().width) && (l >= 0 && l < imgSource.size().height) ) {
std::cout << "k= " << k <<" l= " << l << " wmax= " << wmax << std::endl;
newImgMax.at<float>(k,l) =(float)sum(imgMax, k, l, wmax) / (wmax * wmax);
}
}
}
for k=0 and l=0 the program works fine and returns a value but for k=0 and l=1 the call of the function(sum(imgMax,0,1,1)) doesn't pass,it crashes and shows a segmentation fault core dumped.This is my output:
k= 0 l= 0 wmax= 1
startedX= 0/ startedY= 0
i= 0
j= 0
k= 0 l= 1 wmax= 1
Segmentation fault (core dumped)
Answers
Looks like C++ to me :(
This forum is to support people using Processing and C++ is definitely out of scope for this forum.
C++ in Processing is used for GLSL / Shaders methinks. /:)
https://forum.Processing.org/two/categories/glsl-shaders
openFrameworks is a Processing spin-off based on C++: http://OpenFrameworks.cc/
I forgot about shaders, well spotted.
but that doesn't look like shader code. shader code isn't c++, it's its own thing. and the use of cout looks odd.
i think wrong forum.
But it's strongly based on C/C++ nonetheless: :\">
https://en.Wikipedia.org/wiki/OpenGL_Shading_Language
"OpenGL Shading Language (abbreviated: GLSL or GLslang), is a high-level shading language based on the syntax of the C programming language."
so not "c++" and not "strongly"