Declaration of function and use it
-
@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*)wrote on 19 Jul 2016, 06:32 last edited by@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
wrote on 19 Jul 2016, 06:39 last edited by@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.
wrote on 19 Jul 2016, 06:44 last edited by@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...
wrote on 19 Jul 2016, 07:09 last edited by@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.wrote on 19 Jul 2016, 09:03 last edited by@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...
wrote on 19 Jul 2016, 09:15 last edited byThis post is deleted! -
@gauravsharma0190 Well, I guess you have many issues there...
wrote on 19 Jul 2016, 09:31 last edited by@jsulm
Hey i have posted the error
i can't undersatnd why i am getting these error.
everything is all right. -
@jsulm
Hey i have posted the error
i can't undersatnd why i am getting these error.
everything is all right.@gauravsharma0190 Nothing is all right with this code.
"was not declared in this scope" - you have to check where are those declared or why they are not declared (blur, edge, Mat,...). For example:cedge = Scalar::all(0);
where is cedge declared? You're trying to access a variable which was not declared.
This one says that you first declared the function extern and later static. Why? Since it is just a function it neither has to be static nor extern!
error: 'void CannyThreshold(int, void*)' was declared 'extern' and later 'static' [-fpermissive] static void CannyThreshold(int, void*)
You really have to fix your code! And I really don't understand why you think your code is OK although there are really basic issues (not related to Qt at all)!
-
@gauravsharma0190 Nothing is all right with this code.
"was not declared in this scope" - you have to check where are those declared or why they are not declared (blur, edge, Mat,...). For example:cedge = Scalar::all(0);
where is cedge declared? You're trying to access a variable which was not declared.
This one says that you first declared the function extern and later static. Why? Since it is just a function it neither has to be static nor extern!
error: 'void CannyThreshold(int, void*)' was declared 'extern' and later 'static' [-fpermissive] static void CannyThreshold(int, void*)
You really have to fix your code! And I really don't understand why you think your code is OK although there are really basic issues (not related to Qt at all)!
wrote on 19 Jul 2016, 10:33 last edited by@jsulm
i declare all these variable inside onTrach.cpp file.
blur is function name which is in imgproc.hpp header.
Canny is also function name which is declared in highgui.h header. -
@jsulm
i declare all these variable inside onTrach.cpp file.
blur is function name which is in imgproc.hpp header.
Canny is also function name which is declared in highgui.h header.@gauravsharma0190
Can you post onTrach.cpp and onTrach.h? -
@gauravsharma0190
Can you post onTrach.cpp and onTrach.h?wrote on 19 Jul 2016, 10:41 last edited by gauravsharma0190#include"onTrack.h" #include <opencv2/highgui/highgui.hpp> #include <opencv2/core/core.hpp> #include<opencv2/imgproc/imgproc.hpp> int edgeThresh = 1; //Mat image,gray,edge,cedge; void CannyThreshold(int, void*) { Mat image, gray, edge, cedge; blur(gray, edge, Size(3,3)); // Run the edge detector on grayscale Canny(edge, edge, edgeThresh, edgeThresh*3, 3); cedge = Scalar::all(0); src.copyTo(cedge, edge); imshow("Edge map", cedge); }
.H file
#define ONTRACKBALL_H_ int CannyThreshold(int,void* ); #endif //your code here
Mat is opencv function which is declare in highgui.h
header.
all these functions are present in header which i added in code. -
#include"onTrack.h" #include <opencv2/highgui/highgui.hpp> #include <opencv2/core/core.hpp> #include<opencv2/imgproc/imgproc.hpp> int edgeThresh = 1; //Mat image,gray,edge,cedge; void CannyThreshold(int, void*) { Mat image, gray, edge, cedge; blur(gray, edge, Size(3,3)); // Run the edge detector on grayscale Canny(edge, edge, edgeThresh, edgeThresh*3, 3); cedge = Scalar::all(0); src.copyTo(cedge, edge); imshow("Edge map", cedge); }
.H file
#define ONTRACKBALL_H_ int CannyThreshold(int,void* ); #endif //your code here
Mat is opencv function which is declare in highgui.h
header.
all these functions are present in header which i added in code.@gauravsharma0190 What is Mat and where is it declared?
-
#include"onTrack.h" #include <opencv2/highgui/highgui.hpp> #include <opencv2/core/core.hpp> #include<opencv2/imgproc/imgproc.hpp> int edgeThresh = 1; //Mat image,gray,edge,cedge; void CannyThreshold(int, void*) { Mat image, gray, edge, cedge; blur(gray, edge, Size(3,3)); // Run the edge detector on grayscale Canny(edge, edge, edgeThresh, edgeThresh*3, 3); cedge = Scalar::all(0); src.copyTo(cedge, edge); imshow("Edge map", cedge); }
.H file
#define ONTRACKBALL_H_ int CannyThreshold(int,void* ); #endif //your code here
Mat is opencv function which is declare in highgui.h
header.
all these functions are present in header which i added in code. -
wrote on 19 Jul 2016, 10:50 last edited by
@jsulm
Mat is basically a class with two data parts: the matrix header (containing information such as the size of the matrix, the method used for storing, at which address is the matrix stored, and so on) and a pointer to the matrix containing the pixel values (taking any dimensionality depending on the method chosen for storing) . The matrix header size is constant, however the size of the matrix itself may vary from image to image and usually is larger by orders of magnitude -
@jsulm
Mat is basically a class with two data parts: the matrix header (containing information such as the size of the matrix, the method used for storing, at which address is the matrix stored, and so on) and a pointer to the matrix containing the pixel values (taking any dimensionality depending on the method chosen for storing) . The matrix header size is constant, however the size of the matrix itself may vary from image to image and usually is larger by orders of magnitudewrote on 19 Jul 2016, 11:43 last edited by@gauravsharma0190
Hey jslum
thanks very mush i did it without error
Now new problem arises when i clicked the push button it tells
The program has unexpectedly finished.
/home/pi/Desktop/qt /build-Desktop1-GCC Local/Desktop crashed. -
@gauravsharma0190
Hey jslum
thanks very mush i did it without error
Now new problem arises when i clicked the push button it tells
The program has unexpectedly finished.
/home/pi/Desktop/qt /build-Desktop1-GCC Local/Desktop crashed.@gauravsharma0190 Most probably it crashes because of an invalid pointer. Debug your application step by step to see where exactly it crashes.
61/93