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. Qt - Opencv background subtraction issue
Forum Updated to NodeBB v4.3 + New Features

Qt - Opencv background subtraction issue

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 1.7k Views 2 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.
  • Y Offline
    Y Offline
    yjt8
    wrote on last edited by
    #1

    Hi there! I'm using Qt5.8 with Visual Studio 2017. The below piece of OpenCV code works well in VS, but when I run it using Qt Creator, it doesn't seem to work.

    cv::Mat frame, output;
    Ptr<BackgroundSubtractor> bgS = createBackgroundSubtractorMOG2();
    .
    .
    cvtColor(frame, output, CV_BGR2GRAY);
    bgS->apply(frame, output);

    The background subtractor doesn't seem to work (but no error is thrown) and output is showing blank (plain gray color) whereas this is working fine in VS. Anyone encountered this issue before?

    Thanks in advance.

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi
      If you mean "run in creator" that you compile it via creator with same vs compiler or
      is it other compiler in Creator ? ( like mingw)

      In the project folder, there is a run environment settings.
      You might need to add a path to the opencv dlls for it to find them.

      Else it will work the same as Creator is just an editor.

      Y 1 Reply Last reply
      0
      • mrjjM mrjj

        Hi
        If you mean "run in creator" that you compile it via creator with same vs compiler or
        is it other compiler in Creator ? ( like mingw)

        In the project folder, there is a run environment settings.
        You might need to add a path to the opencv dlls for it to find them.

        Else it will work the same as Creator is just an editor.

        Y Offline
        Y Offline
        yjt8
        wrote on last edited by
        #3

        @mrjj
        i'm running using vs compiler (CDB, not mingw).

        mrjjM 1 Reply Last reply
        0
        • Y yjt8

          @mrjj
          i'm running using vs compiler (CDB, not mingw).

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @yjt8
          Then it must be the loading of the dlls.
          Since Creator it self cannot change how code works.

          Y 1 Reply Last reply
          1
          • mrjjM mrjj

            @yjt8
            Then it must be the loading of the dlls.
            Since Creator it self cannot change how code works.

            Y Offline
            Y Offline
            yjt8
            wrote on last edited by
            #5

            sorry for my late reply. have managed to resolve this - it's not a Qt issue. When i port the codes from C++ to Qt, i have inadvertently initialized the variables inside my Qt Timer event, causing the weird behavior.

            1 Reply Last reply
            1
            • Pablo J. RoginaP Offline
              Pablo J. RoginaP Offline
              Pablo J. Rogina
              wrote on last edited by
              #6

              @yjt8 if your problem is gone, please don't forget to mark your post as solved! Thanks.

              Upvote the answer(s) that helped you solve the issue
              Use "Topic Tools" button to mark your post as Solved
              Add screenshots via postimage.org
              Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

              1 Reply Last reply
              1

              • Login

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