• DepthAI-v2
  • DepthAI app fullscreen mode and Raspberry Pi Zero error.

Hi Ram,

This is an extremely well timed question. So the reason for the trouble on Pi Zero is because the Armv6 wheels would not build correctly in Pi Wheels. But actually today this was fixed:
https://github.com/piwheels/piwheels/pull/276

So now prebuilt wheels will work from now on on pi zero. This is quite convenient for Pi Zero folks using DepthAI. :-)

The thing I don't know is how long it will take for DepthAI (and OpenCV) to build for Pi Zero. As I think there's automation that we don't have control of involved. I think @GergelySzabolcs may know though.

Thanks,
Brandon

    GergelySzabolcs - thanks!

    So ramkunchur - we will likely do another release on Monday (if not sooner; discussing internally), so then that will take advantage of this new fix from PiWheels, resulting in pre-built wheels for the Pi Zero.

    Thoughts?

    Thanks,
    Brandon

      Hi Brandon & GergelySzabolcs

      Thanks so much for your time and reply.

      So this means probably Monday or next week, we need to install latest version of depthai via pip or sudo to be able to run gen2 programs on Raspberry Pi Zero, will wait for new release.

      Can you please also address my second question pertaining to running Python depthai app in fullscreen mode?

      Thanks again for your time and help.

      Thanks & Best Regards,
      Ram

      Yes, that's right WRT the release. We have a pre-built binary somewhere that we built actually on a Pi Zero too, if you didn't want to wait. I can't immediately find it but it's on this forum... somewhere.

      So on the second question, I dodged it because I don't know. Eeeh. :-). @dhruvsheth-ai probably knows though. :-)

        Thanks Brandon
        @dhruvsheth-ai , will it be possible for you to answer my query? this seems like straightforward solution (I've achieved this many times on non-depthAI cameras), somehow it doesn't seem to work on depthAI or I'm doing something incorrect.

        Thanks a lot again!

        Thanks & Best Regards,
        Ram

          Hi dhruvsheth-ai...
          Thanks a lot...

          While we are at it, also need some inputs on how to start python program on raspberry pi startup... I've tried all possible options, doesn't seem to work, I have seen in some tutorials that depthai python program runs on RPi startup...so thought is easier to ask in this forum to get tried and tested method rather than experimenting.

          Thanks & Best Regards,
          Ram

            Hi ramkunchur it seems you're correct. I couldn't find a way to initialise the depthai python script in the preferred environment when the raspberry Pi boots up. However I'm working on this and I hope to get back with a solution by tomorrow.

              Hi dhruvsheth-ai .
              I remember seeing this start-up initialization in action on one YT video, probably hosted by @Brandon...

              Nevertheless, I'll wait for your response, not able to automatically run python program on startup might be a big issue as not all apps can be started manually, especially standalone embedded devices, so there has to be solution for this.

              I'll explore as well in case I'm able to figure something out....

              BTW, any update on full screen mode?

              Thanks for your time and help.

              Thanks & Best Regards,
              Ram

              Hi @ramkunchur so, a simple way to do fullscreen mode while also maintaining desired resolution is using this -

              #!/usr/bin/env python3
              
              import cv2
              import depthai as dai
              
              # Start defining a pipeline
              pipeline = dai.Pipeline()
              
              # Define a source - color camera
              camRgb = pipeline.createColorCamera()
              camRgb.setPreviewSize(192, 108)
              camRgb.setBoardSocket(dai.CameraBoardSocket.RGB)
              camRgb.setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P)
              camRgb.setInterleaved(False)
              camRgb.setColorOrder(dai.ColorCameraProperties.ColorOrder.RGB)
              
              # Create output
              xoutRgb = pipeline.createXLinkOut()
              xoutRgb.setStreamName("rgb")
              camRgb.preview.link(xoutRgb.input)
              
              # Pipeline is defined, now we can connect to the device
              with dai.Device(pipeline) as device:
                  # Start pipeline
                  device.startPipeline()
              
                  # Output queue will be used to get the rgb frames from the output defined above
                  qRgb = device.getOutputQueue(name="rgb", maxSize=4, blocking=False)
              
                  while True:
                      inRgb = qRgb.get()  # blocking call, will wait until a new data has arrived
              
                      # Retrieve 'bgr' (opencv format) frame
                      cv2.namedWindow("bgr", cv2.WND_PROP_FULLSCREEN)
                      cv2.setWindowProperty("bgr",cv2.WND_PROP_FULLSCREEN,
                             cv2.WINDOW_FULLSCREEN)
                      cv2.imshow("bgr", cv2.resize(inRgb.getCvFrame(), (1920, 1080)))
              
                      if cv2.waitKey(1) == ord('q'):
                          break

              So here you can set the desired resolution input for the image frame using setPreviewsize, but ofcourse when you go fullscreen, you need to take into account that the output resolution might look low taking into account the input res. So, set a value for the output resolution based on your screen resolution from here -
              cv2.imshow("bgr", cv2.resize(inRgb.getCvFrame(), (1920, 1080)))
              and this will make the output go fullscreen.

                Hi dhruvsheth-ai ...

                Thanks , I've already tried all most of these options..
                Either the python program doesn't open once raspberry Pi boots up or I get import depthai...no module named depthai..

                The closest I came to resolving this issue is using bashrc, however, this works only when we open terminal manually... Let's keep looking, please let me know if you find something, this is quite a necessary feature...

                Thanks & Best Regards,
                Ram

                  ramkunchur It's mainly because the script doesn't default to a virtual env when it initiates. So, if you do not have library version interference problems with the default environment, you can install depthai wihtout virtual environment. That should work out.

                    Hi dhruvsheth-ai...
                    I've not used virtual environment to run my programs, I'm able to run on default system environment...
                    Co-incidently, I have tried all ways (4) from a different article from same website except the crontab
                    😀 --> https://www.dexterindustries.com/howto/run-a-program-on-your-raspberry-pi-at-startup/

                    The link you shared is from same website, but article is specific to crontab...
                    https://www.dexterindustries.com/howto/auto-run-python-programs-on-the-raspberry-pi/

                    I'll give crontab method a shot and update you,,,, probably it should work...

                    Thanks & Best Regards,
                    Ram

                    Hi dhruvsheth-ai ...

                    I'm able to run the app in fullscreen mode...it is by making some modifications, if I use inRgb.getCvFrame(), I get output in full-screen mode but this doesn't have my inference results shown, modified the code which I had shared earlier and able to get in full screen....thanks for providing inputs...

                    Regarding start up... the crontab solution doesn't work as well, reason is if we use sudo python, we get an error unable to find module import depthai.

                    We need to figure this out...it's quite important..

                    Thanks & Best Regards,
                    Ram