Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Declaration of function and use it
Forum Updated to NodeBB v4.3 + New Features

Declaration of function and use it

Scheduled Pinned Locked Moved Unsolved General and Desktop
93 Posts 4 Posters 59.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G gauravsharma0190

    @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.

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #65

    @gauravsharma0190
    Can you post onTrach.cpp and onTrach.h?

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    G 1 Reply Last reply
    0
    • jsulmJ jsulm

      @gauravsharma0190
      Can you post onTrach.cpp and onTrach.h?

      G Offline
      G Offline
      gauravsharma0190
      wrote on last edited by gauravsharma0190
      #66

      @jsulm

      #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.

      jsulmJ 2 Replies Last reply
      0
      • G gauravsharma0190

        @jsulm

        #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.

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #67

        @gauravsharma0190 What is Mat and where is it declared?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • G gauravsharma0190

          @jsulm

          #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.

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #68

          @gauravsharma0190 Didn't you forget

          using namespace cv;
          

          in the cpp file?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          G 1 Reply Last reply
          0
          • jsulmJ jsulm

            @gauravsharma0190 Didn't you forget

            using namespace cv;
            

            in the cpp file?

            G Offline
            G Offline
            gauravsharma0190
            wrote on last edited by
            #69

            @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

            G 1 Reply Last reply
            0
            • G gauravsharma0190

              @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

              G Offline
              G Offline
              gauravsharma0190
              wrote on last edited by
              #70

              @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.

              jsulmJ 1 Reply Last reply
              0
              • G gauravsharma0190

                @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.

                jsulmJ Offline
                jsulmJ Offline
                jsulm
                Lifetime Qt Champion
                wrote on last edited by
                #71

                @gauravsharma0190 Most probably it crashes because of an invalid pointer. Debug your application step by step to see where exactly it crashes.

                https://forum.qt.io/topic/113070/qt-code-of-conduct

                G 1 Reply Last reply
                0
                • jsulmJ jsulm

                  @gauravsharma0190 Most probably it crashes because of an invalid pointer. Debug your application step by step to see where exactly it crashes.

                  G Offline
                  G Offline
                  gauravsharma0190
                  wrote on last edited by
                  #72

                  @jsulm
                  Hello sir
                  i debug the programme but when i press button it tells
                  the inferior stooped because it receives signal from OS
                  Signal name SIGABRT
                  Signal mean Aborted.
                  Now how to solve it

                  jsulmJ 1 Reply Last reply
                  0
                  • G gauravsharma0190

                    @jsulm
                    Hello sir
                    i debug the programme but when i press button it tells
                    the inferior stooped because it receives signal from OS
                    Signal name SIGABRT
                    Signal mean Aborted.
                    Now how to solve it

                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by jsulm
                    #73

                    @gauravsharma0190 Put a breakpoint in the slot which is called when you press the button and check where exactly it crashes.

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    G 1 Reply Last reply
                    1
                    • G Offline
                      G Offline
                      gauravsharma0190
                      wrote on last edited by gauravsharma0190
                      #74

                      IT CRASHES WHERE FUNCTION ontrack()
                      defination
                      Canny(edge, edge, edgeThresh, edgeThresh*3, 3);
                      kernel_size issue i think.
                      int kernel_size =3;
                      here

                      1 Reply Last reply
                      0
                      • jsulmJ jsulm

                        @gauravsharma0190 Put a breakpoint in the slot which is called when you press the button and check where exactly it crashes.

                        G Offline
                        G Offline
                        gauravsharma0190
                        wrote on last edited by
                        #75

                        @jsulm
                        It crashes when i press the push button .
                        I debugged it and found it creshes when my function call.
                        Error found->it takes signal from OS.
                        Now How to fix it.

                        jsulmJ 2 Replies Last reply
                        0
                        • G gauravsharma0190

                          @jsulm
                          It crashes when i press the push button .
                          I debugged it and found it creshes when my function call.
                          Error found->it takes signal from OS.
                          Now How to fix it.

                          jsulmJ Offline
                          jsulmJ Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on last edited by
                          #76

                          @gauravsharma0190 How to fix what?
                          What do you mean by "Error found->it takes signal from OS" - what OS signal do you mean? Do you mean SIGABRT?
                          I don't know how to fix it because I have no idea what the problem is. But usually such problems are caused by bugs in applications. You have to check your code and see what is wrong at the line where your application crashes.

                          https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0
                          • G gauravsharma0190

                            @jsulm
                            It crashes when i press the push button .
                            I debugged it and found it creshes when my function call.
                            Error found->it takes signal from OS.
                            Now How to fix it.

                            jsulmJ Offline
                            jsulmJ Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on last edited by
                            #77

                            @gauravsharma0190 Can you post the code and mark the line where it crashes?

                            https://forum.qt.io/topic/113070/qt-code-of-conduct

                            G 1 Reply Last reply
                            0
                            • jsulmJ jsulm

                              @gauravsharma0190 Can you post the code and mark the line where it crashes?

                              G Offline
                              G Offline
                              gauravsharma0190
                              wrote on last edited by gauravsharma0190
                              #78

                              @jsulm
                              Mainwindow.cpp

                              void MainWindow::on_onTrackball_clicked()
                              {
                                  int threshold_value = 0;
                                  int threshold_type = 3;
                                  int const max_value = 255;
                                  int const max_type = 4;
                                 // int const max_BINARY_value = 255;
                              
                                  Mat src, src_gray, dst;
                                //  char* window_name = "Threshold Demo";
                              
                                  //char* trackbar_type = "Type: \n 0: Binary \n 1: Binary Inverted \n 2: Truncate \n 3: To Zero \n 4: To Zero Inverted";
                                  //char* trackbar_value = "Value";
                              
                              
                              
                              
                                  /// Load image
                                  src = imread( "/home/pi/Desktop/b4.jpg");
                              
                              
                                    /// Convert the image to Gray
                                    cvtColor( src, src_gray, CV_BGR2GRAY );
                              
                                    /// Create a window to display results
                                    namedWindow( "Threshold", CV_WINDOW_AUTOSIZE );
                              
                                    /// Create Trackbar to choose type of Threshold
                                    createTrackbar( "Type: \n 0: Binary \n 1: Binary Inverted \n 2: Truncate \n 3: To Zero \n 4: To Zero Inverted","Threshold", &threshold_type, max_type, Threshold_Demo );
                              
                                    createTrackbar( "value","Threshold", &threshold_value, max_value, Threshold_Demo );
                              
                                    /// Call the function to initialize
                              @@@   ***Threshold_Demo( 0, 0)***
                              
                              
                              }
                              

                              onTrack.h

                              #ifndef ONTRACKBALL_H_
                              #define ONTRACKBALL_H_
                                void Threshold_Demo( int, void* );
                              #endif
                              

                              ontrack.cpp

                              void Threshold_Demo( int, void* )
                              {
                                /* 0: Binary
                                   1: Binary Inverted
                                   2: Threshold Truncated
                                   3: Threshold to Zero
                                   4: Threshold to Zero Inverted
                                 */
                              
                              @@threshold( src_gray, dst, threshold_value, max_BINARY_value,threshold_type );
                              
                                imshow("Threshold", dst );
                              

                              Here @---> Error

                              jsulmJ 1 Reply Last reply
                              0
                              • G gauravsharma0190

                                @jsulm
                                Mainwindow.cpp

                                void MainWindow::on_onTrackball_clicked()
                                {
                                    int threshold_value = 0;
                                    int threshold_type = 3;
                                    int const max_value = 255;
                                    int const max_type = 4;
                                   // int const max_BINARY_value = 255;
                                
                                    Mat src, src_gray, dst;
                                  //  char* window_name = "Threshold Demo";
                                
                                    //char* trackbar_type = "Type: \n 0: Binary \n 1: Binary Inverted \n 2: Truncate \n 3: To Zero \n 4: To Zero Inverted";
                                    //char* trackbar_value = "Value";
                                
                                
                                
                                
                                    /// Load image
                                    src = imread( "/home/pi/Desktop/b4.jpg");
                                
                                
                                      /// Convert the image to Gray
                                      cvtColor( src, src_gray, CV_BGR2GRAY );
                                
                                      /// Create a window to display results
                                      namedWindow( "Threshold", CV_WINDOW_AUTOSIZE );
                                
                                      /// Create Trackbar to choose type of Threshold
                                      createTrackbar( "Type: \n 0: Binary \n 1: Binary Inverted \n 2: Truncate \n 3: To Zero \n 4: To Zero Inverted","Threshold", &threshold_type, max_type, Threshold_Demo );
                                
                                      createTrackbar( "value","Threshold", &threshold_value, max_value, Threshold_Demo );
                                
                                      /// Call the function to initialize
                                @@@   ***Threshold_Demo( 0, 0)***
                                
                                
                                }
                                

                                onTrack.h

                                #ifndef ONTRACKBALL_H_
                                #define ONTRACKBALL_H_
                                  void Threshold_Demo( int, void* );
                                #endif
                                

                                ontrack.cpp

                                void Threshold_Demo( int, void* )
                                {
                                  /* 0: Binary
                                     1: Binary Inverted
                                     2: Threshold Truncated
                                     3: Threshold to Zero
                                     4: Threshold to Zero Inverted
                                   */
                                
                                @@threshold( src_gray, dst, threshold_value, max_BINARY_value,threshold_type );
                                
                                  imshow("Threshold", dst );
                                

                                Here @---> Error

                                jsulmJ Offline
                                jsulmJ Offline
                                jsulm
                                Lifetime Qt Champion
                                wrote on last edited by
                                #79

                                @gauravsharma0190 What are src_gray, dst, threshold_value, max_BINARY_value,threshold_type? Where are they defined and initialized? Please note: these are NOT same as in MainWindow::on_onTrackball_clicked()!

                                void Threshold_Demo( int, void* )
                                {
                                  /* 0: Binary
                                     1: Binary Inverted
                                     2: Threshold Truncated
                                     3: Threshold to Zero
                                     4: Threshold to Zero Inverted
                                   */
                                
                                @@threshold( src_gray, dst, threshold_value, max_BINARY_value,threshold_type );
                                
                                  imshow("Threshold", dst );
                                
                                

                                https://forum.qt.io/topic/113070/qt-code-of-conduct

                                G 1 Reply Last reply
                                0
                                • jsulmJ jsulm

                                  @gauravsharma0190 What are src_gray, dst, threshold_value, max_BINARY_value,threshold_type? Where are they defined and initialized? Please note: these are NOT same as in MainWindow::on_onTrackball_clicked()!

                                  void Threshold_Demo( int, void* )
                                  {
                                    /* 0: Binary
                                       1: Binary Inverted
                                       2: Threshold Truncated
                                       3: Threshold to Zero
                                       4: Threshold to Zero Inverted
                                     */
                                  
                                  @@threshold( src_gray, dst, threshold_value, max_BINARY_value,threshold_type );
                                  
                                    imshow("Threshold", dst );
                                  
                                  
                                  G Offline
                                  G Offline
                                  gauravsharma0190
                                  wrote on last edited by
                                  #80

                                  @jsulm
                                  Hey Good morning
                                  These are defined in the same function .cpp files.
                                  Yes These are not in mainwindow

                                  jsulmJ 1 Reply Last reply
                                  0
                                  • G gauravsharma0190

                                    @jsulm
                                    Hey Good morning
                                    These are defined in the same function .cpp files.
                                    Yes These are not in mainwindow

                                    jsulmJ Offline
                                    jsulmJ Offline
                                    jsulm
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #81

                                    @gauravsharma0190 Did you initialize these variables? Do they have correct values when you call threshold()?

                                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    G 1 Reply Last reply
                                    0
                                    • jsulmJ jsulm

                                      @gauravsharma0190 Did you initialize these variables? Do they have correct values when you call threshold()?

                                      G Offline
                                      G Offline
                                      gauravsharma0190
                                      wrote on last edited by
                                      #82

                                      @jsulm
                                      Yes i initialize these with correct values.

                                      jsulmJ 1 Reply Last reply
                                      0
                                      • G gauravsharma0190

                                        @jsulm
                                        Yes i initialize these with correct values.

                                        jsulmJ Offline
                                        jsulmJ Offline
                                        jsulm
                                        Lifetime Qt Champion
                                        wrote on last edited by
                                        #83

                                        @gauravsharma0190 Are you sure? Did you verify using debugger? If they have correct values then I don't know why it's crashing...

                                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                                        G 1 Reply Last reply
                                        1
                                        • jsulmJ jsulm

                                          @gauravsharma0190 Are you sure? Did you verify using debugger? If they have correct values then I don't know why it's crashing...

                                          G Offline
                                          G Offline
                                          gauravsharma0190
                                          wrote on last edited by
                                          #84

                                          @gauravsharma0190 said:

                                          void MainWindow::on_onTrackball_clicked()
                                          {
                                          int threshold_value = 0;
                                          int threshold_type = 3;
                                          int const max_value = 255;
                                          int const max_type = 4;
                                          // int const max_BINARY_value = 255;

                                          Mat src, src_gray, dst;
                                          

                                          // char* window_name = "Threshold Demo";

                                          //char* trackbar_type = "Type: \n 0: Binary \n 1: Binary Inverted \n 2: Truncate \n 3: To Zero \n 4: To Zero Inverted";
                                          //char* trackbar_value = "Value";
                                          
                                          
                                          
                                          
                                          /// Load image
                                          src = imread( "/home/pi/Desktop/b4.jpg");
                                          
                                          
                                            /// Convert the image to Gray
                                            cvtColor( src, src_gray, CV_BGR2GRAY );
                                          
                                            /// Create a window to display results
                                            namedWindow( "Threshold", CV_WINDOW_AUTOSIZE );
                                          
                                            /// Create Trackbar to choose type of Threshold
                                            createTrackbar( "Type: \n 0: Binary \n 1: Binary Inverted \n 2: Truncate \n 3: To Zero \n 4: To Zero Inverted","Threshold", &threshold_type, max_type, Threshold_Demo );
                                          
                                            createTrackbar( "value","Threshold", &threshold_value, max_value, Threshold_Demo );
                                          
                                            /// Call the function to initialize
                                          

                                          @@@ Threshold_Demo( 0, 0)

                                          }

                                          When I Comment the line Threshold _demo everything went OK!!!
                                          Results are coming but when i uncomment it everything crashes.

                                          jsulmJ 1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved