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. Running bash script from Qt using QProcess or system() give difference result from terminal
Forum Updated to NodeBB v4.3 + New Features

Running bash script from Qt using QProcess or system() give difference result from terminal

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 580 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.
  • W Offline
    W Offline
    Wong
    wrote on 7 Nov 2022, 09:36 last edited by
    #1

    Hi..

    I am trying the capture the image from usb camera using QProcess to run bash file. My bash script content is

    mplayer -quiet -tv device=/dev/video0 -frames 1 -vf-add screenshot tv://

    When I run this bash script from the terminal, it works fine (see picture)

    However, when I run this bash script from within qt using

    QProcess process ;
    process.startDetached("/bin/bash", QStringList() << "-c" << "/path_to_file/capture.bash");

    there is something mixed up with the camera's buffer. The resulted picture looks like an superimposed version from previous position here (the camera is on a pan-tilt base.

    Has anyone ever encountered this problem?

    J 1 Reply Last reply 7 Nov 2022, 09:40
    0
    • W Wong
      7 Nov 2022, 09:36

      Hi..

      I am trying the capture the image from usb camera using QProcess to run bash file. My bash script content is

      mplayer -quiet -tv device=/dev/video0 -frames 1 -vf-add screenshot tv://

      When I run this bash script from the terminal, it works fine (see picture)

      However, when I run this bash script from within qt using

      QProcess process ;
      process.startDetached("/bin/bash", QStringList() << "-c" << "/path_to_file/capture.bash");

      there is something mixed up with the camera's buffer. The resulted picture looks like an superimposed version from previous position here (the camera is on a pan-tilt base.

      Has anyone ever encountered this problem?

      J Offline
      J Offline
      JonB
      wrote on 7 Nov 2022, 09:40 last edited by
      #2

      @Wong
      There is no effective difference between running a bash script directly from e.g. a terminal versus running QProcess::startDetached("/bin/bash", QStringList() << "-c" << "/path_to_file/capture.bash"). So I don't know why you find it is behaving any differently.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        Jessevg
        wrote on 7 Nov 2022, 14:59 last edited by
        #3

        There would be no effective difference here, this looks more like your camera doing something funky with it's framebuffers, I don't think Qt would be doing something so wrong it's messing up framebuffer data that's captured from inside a script you're running

        1 Reply Last reply
        1
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 7 Nov 2022, 19:54 last edited by
          #4

          Hi,

          Since your bash script is basically a one liner, can you check what happens if you call mplayer directly from it ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          1/4

          7 Nov 2022, 09:36

          • Login

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