Declaration of function and use it
-
@gauravsharma0190 said:
CannyThreshold
this function ?
CannyThreshold
that you call with
CannyThreshold(0, 0);and you do include the .h file where its defined?
-
@gauravsharma0190 said:
CannyThreshold
this function ?
CannyThreshold
that you call with
CannyThreshold(0, 0);and you do include the .h file where its defined?
@mrjj
it is defined as///ontrack.h/// #ifndef __ONTRACK_h #define __ONTRACK_h void cannyThresold(int,void*); #endif ......
///ontrack.cpp #include "ontrack.h" #include<opencv2/opencv.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/core/core.hpp> void CannyThreshold(int, void*) { /// Reduce noise with a kernel 3x3 blur( src_gray, detected_edges, Size(3,3) ); /// Canny detector Canny( detected_edges, detected_edges, lowThreshold, lowThreshold*ratio, kernel_size ); /// Using Canny's output as a mask, we display our result dst = Scalar::all(0); src.copyTo( dst, detected_edges); imshow( window_name, dst ); }
.....
thus i include ontrack.h in mainwindow.cpp code.
but error occurs.
Why??
i can't understand. -
I dont understand either.
Seems fine.
try to define a test function
as in
ontrack.h
void mytest();
and call that from main.If that is still not known, it means that mainwinow do not really include ontrack.h for some reason.
-
@mrjj
it is defined as///ontrack.h/// #ifndef __ONTRACK_h #define __ONTRACK_h void cannyThresold(int,void*); #endif ......
///ontrack.cpp #include "ontrack.h" #include<opencv2/opencv.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/core/core.hpp> void CannyThreshold(int, void*) { /// Reduce noise with a kernel 3x3 blur( src_gray, detected_edges, Size(3,3) ); /// Canny detector Canny( detected_edges, detected_edges, lowThreshold, lowThreshold*ratio, kernel_size ); /// Using Canny's output as a mask, we display our result dst = Scalar::all(0); src.copyTo( dst, detected_edges); imshow( window_name, dst ); }
.....
thus i include ontrack.h in mainwindow.cpp code.
but error occurs.
Why??
i can't understand.@gauravsharma0190 You call it like this CannyThreshold(0, 0); and in ontrack.cpp it is defined like void CannyThreshold(int, void*). But in ontrack.h it is void cannyThresold(int,void*); please fix the name of the function.
-
@gauravsharma0190 You call it like this CannyThreshold(0, 0); and in ontrack.cpp it is defined like void CannyThreshold(int, void*). But in ontrack.h it is void cannyThresold(int,void*); please fix the name of the function.
-
@mrjj
I fix canny as Canny in .h file
but again error occurs. -
@gauravsharma0190 You call it like this CannyThreshold(0, 0); and in ontrack.cpp it is defined like void CannyThreshold(int, void*). But in ontrack.h it is void cannyThresold(int,void*); please fix the name of the function.
@jsulm
Hey i fixed it .But again error. -
@jsulm
Hey i fixed it .But again error.@gauravsharma0190 "But again error" - why don't you say what error you get now?
-
@gauravsharma0190 "But again error" - why don't you say what error you get now?
@jsulm
yes it tells undefined reference to 'CannyThresold(int,void*)'.
collect2:error ld returned 1 exit status. -
@jsulm
yes it tells undefined reference to 'CannyThresold(int,void*)'.
collect2:error ld returned 1 exit status.@gauravsharma0190 Is ontrack.cpp part of your project and is it built?
"undefined reference to 'CannyThresold(int,void*)" - means linker cannot find CannyThresold(int,void*) -
@gauravsharma0190 Is ontrack.cpp part of your project and is it built?
"undefined reference to 'CannyThresold(int,void*)" - means linker cannot find CannyThresold(int,void*)@jsulm
Actually i put .h and .cpp file in my qt project folder. -
@jsulm
Actually i put .h and .cpp file in my qt project folder.@gauravsharma0190 But did you add them to your project?
They should be in the PRO file, like:SOURCES += main.cpp\ mainwindow.cpp\ ontrack.cpp HEADERS += mainwindow.h\ ontrack.h
-
@gauravsharma0190 But did you add them to your project?
They should be in the PRO file, like:SOURCES += main.cpp\ mainwindow.cpp\ ontrack.cpp HEADERS += mainwindow.h\ ontrack.h
@jsulm
i added it but gives error as
parse error onTrack.cpp
Makefile error 3 -
@jsulm
i added it but gives error as
parse error onTrack.cpp
Makefile error 3@gauravsharma0190 After changing PRO file you need to rerun qmake (right-click on the project in QtCreator and then "Run qmake". Then do a rebuild.
-
@gauravsharma0190 After changing PRO file you need to rerun qmake (right-click on the project in QtCreator and then "Run qmake". Then do a rebuild.
@jsulm
I done it
Now gives many error regarding onTrack.cpp file. -
@jsulm
I done it
Now gives many error regarding onTrack.cpp file.@gauravsharma0190 Well, I guess you have many issues there...
-
@gauravsharma0190 Well, I guess you have many issues there...
@jsulm
Yeap.
are they function's issuses or anything.
I can't undersatnd everything is all right so Why all these issuses are there.
I will send you these issue. -
@jsulm
Yeap.
are they function's issuses or anything.
I can't undersatnd everything is all right so Why all these issuses are there.
I will send you these issue.@gauravsharma0190
Here are all the errors
.../home/pi/Desktop/qt/Desktop1/onTrackBall.cpp:9: error: 'blur' was not declared in this scope blur(gray, edge, Size(3,3)); ^ /home/pi/Desktop/qt/Desktop1/onTrackBall.cpp:6: error: 'Mat' does not name a type Mat image, gray, edge, cedge; ^ /home/pi/Desktop/qt/Desktop1/onTrackBall.cpp:7: error: 'void CannyThreshold(int, void*)' was declared 'extern' and later 'static' [-fpermissive] static void CannyThreshold(int, void*) ^ /home/pi/Desktop/qt/Desktop1/onTrackBall.cpp:-1: In function 'void CannyThreshold(int, void*)': /home/pi/Desktop/qt/Desktop1/onTrackBall.cpp:9: error: 'edge' was not declared in this scope blur(gray, edge, Size(3,3)); ^ /home/pi/Desktop/qt/Desktop1/onTrackBall.cpp:9: error: 'edge' was not declared in this scope blur(gray, edge, Size(3,3)); ^ /home/pi/Desktop/qt/Desktop1/onTrackBall.cpp:9: error: 'blur' was not declared in this scope blur(gray, edge, Size(3,3)); ^ /home/pi/Desktop/qt/Desktop1/onTrackBall.cpp:12: error: 'Canny' was not declared in this scope Canny(edge, edge, edgeThresh, edgeThresh*3, 3); ^ /home/pi/Desktop/qt/Desktop1/onTrackBall.cpp:13: error: 'cedge' was not declared in this scope cedge = Scalar::all(0); ^ /home/pi/Desktop/qt/Desktop1/onTrackBall.cpp:15: error: 'src' was not declared in this scope src.copyTo(cedge, edge); ^ /home/pi/Desktop/qt/Desktop1/onTrackBall.cpp:16: error: 'imshow' was not declared in this scope imshow("Edge map", cedge); ^ /usr/local/include/opencv2/highgui/highgui.hpp:78: note: 'cv::imshow' CV_EXPORTS_W void imshow(const string& winname, InputArray mat);
-
@gauravsharma0190 Well, I guess you have many issues there...
This post is deleted! -
@gauravsharma0190 Well, I guess you have many issues there...
@jsulm
Hey i have posted the error
i can't undersatnd why i am getting these error.
everything is all right.