Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

expected unqualified-id before ‘-’ token

I am trying to write a basic program for image processing and i am stuck at defining the kernel, i am getting the above error and i dont know what i am doing wrong. i tried to search and did not find anything and i am little new to both c++ and opencv

the code i have wrote is

#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "iostream"

using namespace cv;
using namespace std;


int c = 1;
int *c_Address = &c;
int initialsharp = 1;
Mat kernel = Mat_<double>(3,3) << -c, -c, -c, -c, 8*c+1, -c, -c, -c, -c ;

void trackbarPosSharp(int pos, void *y)
{
*c_Address = pos;
Mat src = imread( "blurry_moon.tif", CV_LOAD_IMAGE_GRAYSCALE );
Mat dst = Mat::zeros( src.size(), src.type() );
filter2D(src, dst, -1, kernel);
imshow("Output", dst);
 }

 int main( )
 {
Mat src = imread( "blurry_moon.tif", CV_LOAD_IMAGE_GRAYSCALE );

//equalizeHist( channel[0], channel[0] );

namedWindow( "Original image", CV_WINDOW_AUTOSIZE );
imshow( "Original image", src );
src.release();

namedWindow("Output", CV_WINDOW_AUTOSIZE);
createTrackbar("Shrapening level ","Output", &initialsharp, 10, trackbarPosSharp);
trackbarPosSharp(1, 0);
waitKey(0);
return 0;
}

expected unqualified-id before ‘-’ token

I am trying to write a basic program for image processing and i am stuck at defining the kernel, i am getting the above error and i dont know what i am doing wrong. i tried to search and did not find anything and i am little new to both c++ and opencv

the error pops up from the second "c" in kernel i defined and also i tried using array like

int i,j;
for( i=0; i<3; ++i){
    for( j=0; j<3; ++j){
    kernel[i][j] = -1*c;
    }
}
kernel[2][2] = 8*c+1;

then also i am getting

expected unqualified-id before ‘for’ token

'i' does not have a type

expected unqualified-id before '++’ token

the code i have wrote is

#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "iostream"

using namespace cv;
using namespace std;


int c = 1;
int *c_Address = &c;
int initialsharp = 1;
Mat kernel = Mat_<double>(3,3) << -c, -c, -c, -c, 8*c+1, -c, -c, -c, -c ;

void trackbarPosSharp(int pos, void *y)
{
*c_Address = pos;
Mat src = imread( "blurry_moon.tif", CV_LOAD_IMAGE_GRAYSCALE );
Mat dst = Mat::zeros( src.size(), src.type() );
filter2D(src, dst, -1, kernel);
imshow("Output", dst);
 }

 int main( )
 {
Mat src = imread( "blurry_moon.tif", CV_LOAD_IMAGE_GRAYSCALE );

//equalizeHist( channel[0], channel[0] );

namedWindow( "Original image", CV_WINDOW_AUTOSIZE );
imshow( "Original image", src );
src.release();

namedWindow("Output", CV_WINDOW_AUTOSIZE);
createTrackbar("Shrapening level ","Output", &initialsharp, 10, trackbarPosSharp);
trackbarPosSharp(1, 0);
waitKey(0);
return 0;
}