Hi Eric,
I flashed the bootloader and also flashed a created pipeline.
However, How to make sure that the program is now running on the OAK-D-POE and not on my laptop?

Also I want to know how to trigger and run the program on the OAK-D, as I want to connect my OAK-D-POE only to a PLC and not to a computer/or a microprocessor like (raspberry pi).

thanks!

  • erik replied to this.

    Hello Gaurav3434 , device will probably communicate with the outside world in some way, eg. sending HTTP requests to a server, so you can check on the server if you get expected requests - that's how you check if it works as expected.
    When pipeline is flashed, it will auto-start when it gets powered on, so you don't need to trigger/run it.
    Thanks, Erik

    Hello Eric, thanks for the response!
    I got HTTP request on the server, its working!
    However, I think I'm doing something wrong while flashing pipeline, because even after flashing, the program is still running on my laptop but not on OAK-D device.

    Also let me know how do I upload my python script on OAK-D device?

    And should I run flashing pipeline program only ones? OR should I add this program into my main program so it will run every time when the OAK-D is powered ON
    I have run the following program for flashing pipeline, but let me know if this is incorrect!

                     import depthai as dai
                     pipeline = dai.Pipeline()
    
                     (f, bl) = dai.DeviceBootloader.getFirstAvailableDevice()
                     bootloader = dai.DeviceBootloader(bl)
                     progress = lambda p : print(f'Flashing progress: {p*100:.1f}%')
                     bootloader.flash(progress, pipeline)
    • erik replied to this.

      Hello Gaurav3434 , what do you mean the program is running on your laptop?
      The code that you posted has an unpopulated pipeline. As you can see, you only initialize it and flash an empty pipeline, you should add nodes/connections to it. This is how you would flash the HTTP server to the OAK POE (I assume you already flashed bootloader):

      #!/usr/bin/env python3
      
      import depthai as dai
      import time
      
      # Start defining a pipeline
      pipeline = dai.Pipeline()
      
      # Define a source - color camera
      cam = pipeline.create(dai.node.ColorCamera)
      # VideoEncoder
      jpeg = pipeline.create(dai.node.VideoEncoder)
      jpeg.setDefaultProfilePreset(cam.getFps(), dai.VideoEncoderProperties.Profile.MJPEG)
      
      # Script node
      script = pipeline.create(dai.node.Script)
      script.setProcessor(dai.ProcessorType.LEON_CSS)
      script.setScript("""
          from http.server import BaseHTTPRequestHandler
          import socketserver
          import socket
          import fcntl
          import struct
      
          PORT = 8080
          ctrl = CameraControl()
          ctrl.setCaptureStill(True)
      
          def get_ip_address(ifname):
              s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
              return socket.inet_ntoa(fcntl.ioctl(
                  s.fileno(),
                  -1071617759,  # SIOCGIFADDR
                  struct.pack('256s', ifname[:15].encode())
              )[20:24])
      
          class HTTPHandler(BaseHTTPRequestHandler):
              def do_GET(self):
                  if self.path == '/':
                      self.send_response(200)
                      self.end_headers()
                      self.wfile.write(b'<h1>[DepthAI] Hello, world!</h1><p>Click <a href="img">here</a> for an image</p>')
                  elif self.path == '/img':
                      node.io['out'].send(ctrl)
                      jpegImage = node.io['jpeg'].get()
                      self.send_response(200)
                      self.send_header('Content-Type', 'image/jpeg')
                      self.send_header('Content-Length', str(len(jpegImage.getData())))
                      self.end_headers()
                      self.wfile.write(jpegImage.getData())
                  else:
                      self.send_response(404)
                      self.end_headers()
                      self.wfile.write(b'Url not found...')
      
          with socketserver.TCPServer(("", PORT), HTTPHandler) as httpd:
              node.warn(f"Serving at {get_ip_address('re0')}:{PORT}")
              httpd.serve_forever()
      """)
      
      # Connections
      cam.still.link(jpeg.input)
      script.outputs['out'].link(cam.inputControl)
      jpeg.bitstream.link(script.inputs['jpeg'])
      
      (f, bl) = dai.DeviceBootloader.getFirstAvailableDevice()
      bootloader = dai.DeviceBootloader(bl)
      progress = lambda p : print(f'Flashing progress: {p*100:.1f}%')
      bootloader.flash(progress, pipeline)

      Hello Eric, I ran the code you posted, it worked! thanks.
      However, I wish to know, how to edit your code in order to make use of openCV libraries

      for example, I want to draw a small rectangle in the center of the captured image and then stream it from HTTP server.
      So how to edit the HTTP code that you sent me, to draw a rectangle in the middle? could you please send me an edited code?

      Also could you please tell me the line that I should add in my code to set RGB focus manually..
      I tried putting this line but it's still autofocusing:

      camRgb.initialControl.setManualFocus(130)

      • erik replied to this.

        Hello Gaurav3434 , you can't run OpenCV on the OAK devices. We are looking into ways to add simple rectangle drawing/text drawing to the firmware. Currently, one way would be to use custom CV model, more info here.

        The ColorCamera is represented with cam variable, so correct would be to use cam.initialControl.setManualFocus(130). Could you try that out?

        Thanks, Erik

        Hello Eric, thanks for response!

        I want to know what (130) number represents in the following line, is it a distance at which its going to focus, if yes what's the unit mm, cm, m?
        cam.initialControl.setManualFocus(130)

        thanks

        • erik replied to this.

          Hello Gaurav3434 ,
          it's not that "smart", it's actually the position of the lens. Value has to be between 0-255, so in this case the lens is about halfway to the max. In case of OAK-D-POE, this value has focus from 30cm to infinity.
          Thanks, Erik

          2 years later

          I have the same problem in flashing the pipeline. The pipeline works fine with running in host PC but when I tried to make it standalone it successfully flashed but no result. I used the mqtt script in repo but changed the

          with dai.Device(pipeline) as device:

          print('Connected to OAK')
          
          while not device.isClosed():
          
              time.sleep(1)

          to

          (f, bl) = dai.DeviceBootloader.getFirstAvailableDevice()

          bootloader = dai.DeviceBootloader(bl)

          progress = lambda p : print(f'Flashing progress: {p*100:.1f}%')

          bootloader.flash(progress, pipeline, compress=True)

          I didn't recieved any payload

          2 months later

          Hi,

          I want to make object traking system. I'm using just OAK-D camera and S7-1200 PLC. I will define imaginary line on the cam. If the object pass the line , camera will give data/logic 1 to PLC . How can i make it?

          thanks,