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. Issue with threading and opencv
Forum Updated to NodeBB v4.3 + New Features

Issue with threading and opencv

Scheduled Pinned Locked Moved Solved General and Desktop
41 Posts 3 Posters 9.7k 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.
  • KiraK Kira

    @J.Hilk : I have registered it.
    #include "mainwindow.h"
    #include <QApplication>

    int main(int argc, char *argv[])
    {
    qRegisterMetaType< cv::Mat >("cv::Mat");
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    return a.exec();
    

    }

    J.HilkJ Offline
    J.HilkJ Offline
    J.Hilk
    Moderators
    wrote on last edited by
    #16

    @Kira

    the data goes most likely out of scope, as the copy constructor of cv::Mat does actually no coping

    0_1560409629873_2c331f8b-46e4-4408-8567-abe5ac4169e3-image.png

    I had the same issues in my time with opencv.

    ended up converting it to a Image before transferring it from the opencv thread to the normal one.


    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


    Q: What's that?
    A: It's blue light.
    Q: What does it do?
    A: It turns blue.

    KiraK 1 Reply Last reply
    3
    • J.HilkJ J.Hilk

      @Kira

      the data goes most likely out of scope, as the copy constructor of cv::Mat does actually no coping

      0_1560409629873_2c331f8b-46e4-4408-8567-abe5ac4169e3-image.png

      I had the same issues in my time with opencv.

      ended up converting it to a Image before transferring it from the opencv thread to the normal one.

      KiraK Offline
      KiraK Offline
      Kira
      wrote on last edited by
      #17

      @J.Hilk : Just for clarification should i replace this part with cv::clone
      void saveImage(Mat finalImage,String row, String column);

      1 Reply Last reply
      0
      • KiraK Offline
        KiraK Offline
        Kira
        wrote on last edited by
        #18

        @J-Hilk : will try and also i tried to run the program in debug mode and getting the following error.
        0_1560418863054_65dbf469-08ad-429c-bed7-3a5997fe0246-image.png

        Debugger redirects to following line of file of ostream:
        // MANIPULATORS
        template<class _Elem,
        class _Traits> inline
        basic_ostream<_Elem, _Traits>&
        __CLRCALL_OR_CDECL endl(basic_ostream<_Elem, _Traits>& _Ostr)
        { // insert newline and flush stream
        _Ostr.put(_Ostr.widen('\n'));
        _Ostr.flush();
        return (_Ostr);
        }

        0_1560419407453_ee0e3e1d-16a4-4a24-8b13-2cf3c1db7c66-image.png

        And the program quits.
        Can u please explain what may be the relevant reason for error

        jsulmJ 1 Reply Last reply
        0
        • KiraK Kira

          @J-Hilk : will try and also i tried to run the program in debug mode and getting the following error.
          0_1560418863054_65dbf469-08ad-429c-bed7-3a5997fe0246-image.png

          Debugger redirects to following line of file of ostream:
          // MANIPULATORS
          template<class _Elem,
          class _Traits> inline
          basic_ostream<_Elem, _Traits>&
          __CLRCALL_OR_CDECL endl(basic_ostream<_Elem, _Traits>& _Ostr)
          { // insert newline and flush stream
          _Ostr.put(_Ostr.widen('\n'));
          _Ostr.flush();
          return (_Ostr);
          }

          0_1560419407453_ee0e3e1d-16a4-4a24-8b13-2cf3c1db7c66-image.png

          And the program quits.
          Can u please explain what may be the relevant reason for error

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

          @Kira Please post the stack trace after crash

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

          KiraK 1 Reply Last reply
          0
          • jsulmJ jsulm

            @Kira Please post the stack trace after crash

            KiraK Offline
            KiraK Offline
            Kira
            wrote on last edited by
            #20

            @jsulm : I thought this is the stack trace after crash

            jsulmJ 1 Reply Last reply
            0
            • KiraK Kira

              @jsulm : I thought this is the stack trace after crash

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

              @Kira said in Issue with threading and opencv:

              this is the stack trace after crash

              no, it isn't

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

              KiraK 1 Reply Last reply
              0
              • jsulmJ jsulm

                @Kira said in Issue with threading and opencv:

                this is the stack trace after crash

                no, it isn't

                KiraK Offline
                KiraK Offline
                Kira
                wrote on last edited by
                #22

                @jsulm : This is the only thing which i see after crash with exception triggered.
                Is there any other way to do so

                jsulmJ 1 Reply Last reply
                0
                • KiraK Kira

                  @jsulm : This is the only thing which i see after crash with exception triggered.
                  Is there any other way to do so

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

                  @Kira In QtCreator if you start with debugger you will have a stack trace

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

                  KiraK 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @Kira In QtCreator if you start with debugger you will have a stack trace

                    KiraK Offline
                    KiraK Offline
                    Kira
                    wrote on last edited by
                    #24

                    @jsulm : Are you referring to this:
                    0_1560428382736_ecc1a67e-9ef8-4aad-ab64-76c3ed8f112e-image.png
                    Please let me know in case of any issues

                    jsulmJ 1 Reply Last reply
                    0
                    • KiraK Kira

                      @jsulm : Are you referring to this:
                      0_1560428382736_ecc1a67e-9ef8-4aad-ab64-76c3ed8f112e-image.png
                      Please let me know in case of any issues

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

                      @Kira Yes. Now you need to go from top to bottom until you hit first source code file from your project and check it at the line mentioned in the stack trace.

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

                      KiraK 1 Reply Last reply
                      1
                      • jsulmJ jsulm

                        @Kira Yes. Now you need to go from top to bottom until you hit first source code file from your project and check it at the line mentioned in the stack trace.

                        KiraK Offline
                        KiraK Offline
                        Kira
                        wrote on last edited by
                        #26

                        @jsulm : I tried doing it but the error is expected to come after thread running >150 times which is making the debugging process very difficult.
                        I have also sample test case on github can you please go through it for any possible issues.
                        https://github.com/HackersSpirit/ImageProcessor

                        J.HilkJ jsulmJ 2 Replies Last reply
                        0
                        • KiraK Kira

                          @jsulm : I tried doing it but the error is expected to come after thread running >150 times which is making the debugging process very difficult.
                          I have also sample test case on github can you please go through it for any possible issues.
                          https://github.com/HackersSpirit/ImageProcessor

                          J.HilkJ Offline
                          J.HilkJ Offline
                          J.Hilk
                          Moderators
                          wrote on last edited by
                          #27

                          @Kira said in Issue with threading and opencv:

                          150 times

                          you can tell a breakpoint to be ignored for a certain amount of time

                          0_1560506679424_0eaace31-88f0-4376-8417-f745494c6433-image.png


                          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                          Q: What's that?
                          A: It's blue light.
                          Q: What does it do?
                          A: It turns blue.

                          1 Reply Last reply
                          2
                          • KiraK Kira

                            @jsulm : I tried doing it but the error is expected to come after thread running >150 times which is making the debugging process very difficult.
                            I have also sample test case on github can you please go through it for any possible issues.
                            https://github.com/HackersSpirit/ImageProcessor

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

                            @Kira I actually suggested to go through the stack trace after crash from top to bottom. No break points needed for that.

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

                            KiraK 1 Reply Last reply
                            2
                            • jsulmJ jsulm

                              @Kira I actually suggested to go through the stack trace after crash from top to bottom. No break points needed for that.

                              KiraK Offline
                              KiraK Offline
                              Kira
                              wrote on last edited by Kira
                              #29

                              @jsulm :
                              @Kira said in Issue with threading and opencv:

                              @jsulm : Are you referring to this:
                              0_1560428382736_ecc1a67e-9ef8-4aad-ab64-76c3ed8f112e-image.png
                              Please let me know in case of any issues

                              This is the stack trace which i get posted earlier referring from line no 1. It does not point to line of code where program has a break.
                              But line 16 and 17 point to the line of the code.
                              Should i refer those line for particular cause of the program to break
                              Please do let me know if i getting something wrong

                              jsulmJ 1 Reply Last reply
                              0
                              • KiraK Kira

                                @jsulm :
                                @Kira said in Issue with threading and opencv:

                                @jsulm : Are you referring to this:
                                0_1560428382736_ecc1a67e-9ef8-4aad-ab64-76c3ed8f112e-image.png
                                Please let me know in case of any issues

                                This is the stack trace which i get posted earlier referring from line no 1. It does not point to line of code where program has a break.
                                But line 16 and 17 point to the line of the code.
                                Should i refer those line for particular cause of the program to break
                                Please do let me know if i getting something wrong

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

                                @Kira Check your code in that source code at line 16 and 17.

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

                                KiraK 1 Reply Last reply
                                1
                                • jsulmJ jsulm

                                  @Kira Check your code in that source code at line 16 and 17.

                                  KiraK Offline
                                  KiraK Offline
                                  Kira
                                  wrote on last edited by
                                  #31

                                  @jsulm :
                                  Line 16 is pointing to following line in bold:
                                  void ImageMapping::requestReWorkNew()
                                  {
                                  cout<<"Inside requestRework Newwwwwwwwww"<<endl;
                                  const int sleep = 50;
                                  int queueSize = queueImageName.size();
                                  cout<<"Queue size Request Rework New: "<<queueSize<<endl;
                                  if(queueImageName.size()!=0){
                                  //Get the current image number from the list of images
                                  mutex.lock();
                                  _working = true;
                                  _abort = false;
                                  mutex.unlock();
                                  cout<<"Emiting resume work"<<endl;
                                  emit resumeWork();
                                  }else{
                                  cout<<"Signalling retrying"<<endl;

                                      emit retrying();
                                  }
                                  

                                  }

                                  This function is basically a slot triggered by following signal:
                                  connect(imageMapping, SIGNAL(finished()), imageMapping, SLOT(requestReWorkNew()));
                                  connect(imageMapping, SIGNAL(retrying()),imageMapping,SLOT(requestReWorkNew()));

                                  jsulmJ J.HilkJ 2 Replies Last reply
                                  0
                                  • KiraK Kira

                                    @jsulm :
                                    Line 16 is pointing to following line in bold:
                                    void ImageMapping::requestReWorkNew()
                                    {
                                    cout<<"Inside requestRework Newwwwwwwwww"<<endl;
                                    const int sleep = 50;
                                    int queueSize = queueImageName.size();
                                    cout<<"Queue size Request Rework New: "<<queueSize<<endl;
                                    if(queueImageName.size()!=0){
                                    //Get the current image number from the list of images
                                    mutex.lock();
                                    _working = true;
                                    _abort = false;
                                    mutex.unlock();
                                    cout<<"Emiting resume work"<<endl;
                                    emit resumeWork();
                                    }else{
                                    cout<<"Signalling retrying"<<endl;

                                        emit retrying();
                                    }
                                    

                                    }

                                    This function is basically a slot triggered by following signal:
                                    connect(imageMapping, SIGNAL(finished()), imageMapping, SLOT(requestReWorkNew()));
                                    connect(imageMapping, SIGNAL(retrying()),imageMapping,SLOT(requestReWorkNew()));

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

                                    @Kira Are you sure this is the line? The actual line is mentioned in the "Line" column in the stack trace. So, it would be 2129.

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

                                    KiraK 1 Reply Last reply
                                    0
                                    • KiraK Kira

                                      @jsulm :
                                      Line 16 is pointing to following line in bold:
                                      void ImageMapping::requestReWorkNew()
                                      {
                                      cout<<"Inside requestRework Newwwwwwwwww"<<endl;
                                      const int sleep = 50;
                                      int queueSize = queueImageName.size();
                                      cout<<"Queue size Request Rework New: "<<queueSize<<endl;
                                      if(queueImageName.size()!=0){
                                      //Get the current image number from the list of images
                                      mutex.lock();
                                      _working = true;
                                      _abort = false;
                                      mutex.unlock();
                                      cout<<"Emiting resume work"<<endl;
                                      emit resumeWork();
                                      }else{
                                      cout<<"Signalling retrying"<<endl;

                                          emit retrying();
                                      }
                                      

                                      }

                                      This function is basically a slot triggered by following signal:
                                      connect(imageMapping, SIGNAL(finished()), imageMapping, SLOT(requestReWorkNew()));
                                      connect(imageMapping, SIGNAL(retrying()),imageMapping,SLOT(requestReWorkNew()));

                                      J.HilkJ Offline
                                      J.HilkJ Offline
                                      J.Hilk
                                      Moderators
                                      wrote on last edited by
                                      #33

                                      @Kira you can double click on the line (in QtCreator) of the stack trace and it will open the file at the correct line


                                      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                                      Q: What's that?
                                      A: It's blue light.
                                      Q: What does it do?
                                      A: It turns blue.

                                      1 Reply Last reply
                                      0
                                      • jsulmJ jsulm

                                        @Kira Are you sure this is the line? The actual line is mentioned in the "Line" column in the stack trace. So, it would be 2129.

                                        KiraK Offline
                                        KiraK Offline
                                        Kira
                                        wrote on last edited by Kira
                                        #34

                                        @jsulm : Actually i have recreated the issue.the program i am referring now is from github. I have cross checked the line which I highlighted is the same. If u want i can repost the image

                                        KiraK 1 Reply Last reply
                                        0
                                        • KiraK Kira

                                          @jsulm : Actually i have recreated the issue.the program i am referring now is from github. I have cross checked the line which I highlighted is the same. If u want i can repost the image

                                          KiraK Offline
                                          KiraK Offline
                                          Kira
                                          wrote on last edited by
                                          #35

                                          @J-Hilk @jsulm : guys have you gone through the code at github do you see any issue with the threading logic? :)

                                          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