EdmundsJelinskis

  • 15 days ago
  • Joined Mar 13, 2024
  • 0 best answers
  • jakaskerl
    Router is 5-10 y/o, maybe it get some problem with connection.
    Ok, i try use wireshark and check where is packet loss.
    Yes I add half half-duplex for 10/100/1000, same problem, when disable auto negotation, camera lose ping and any connections is not available.

  • jakaskerl Test code is not large, put it all.
    currant-yolov8-1107-480.blob - got 1600 picture 5,79 MB file size.
    Also run small *.blob file = 600 picture ~4MB file size, but problem same.

    from pathlib import Path

    import sys

    import cv2

    import depthai as dai

    import numpy as np

    import time

    # Get argument first

    nnBlobPath = str((Path(_file_).parent / Path('/home/pi/Desktop/WEB_weeder/weights/currant_08052024_server.blob')).resolve().absolute())

    if not Path(nnBlobPath).exists():

    raise FileNotFoundError(f'Required file/s not found, please run "{sys.executable} install_requirements.py"')

    # Label texts

    labelMap = ["currant"] # Assuming there is only one class

    syncNN = True

    # Create pipeline

    pipeline = dai.Pipeline()

    # Define sources and outputs

    camRgb = pipeline.create(dai.node.ColorCamera)

    detectionNetwork = pipeline.create(dai.node.YoloDetectionNetwork)

    xoutRgb = pipeline.create(dai.node.XLinkOut)

    xoutNN = pipeline.create(dai.node.XLinkOut)

    #nnNetworkOut = pipeline.create(dai.node.XLinkOut)

    xoutRgb.setStreamName("rgb")

    xoutNN.setStreamName("detections")

    #nnNetworkOut.setStreamName("nnNetwork")

    # Properties

    camRgb.setPreviewSize(448,448)

    camRgb.setResolution(dai.ColorCameraProperties.SensorResolution.THE_720_P)

    #camRgb.setResolution(dai.ColorCameraProperties.SensorResolution.THE_1080_P) #Var lietot šo resolution

    camRgb.setColorOrder(dai.ColorCameraProperties.ColorOrder.BGR)

    camRgb.setFps(30)

    camRgb.setInterleaved(False)

    detectionNetwork.setBlobPath(nnBlobPath)

    detectionNetwork.setConfidenceThreshold(0.8)

    detectionNetwork.input.setBlocking(False)

    detectionNetwork.setNumInferenceThreads(2)

    #detectionNetwork.input.setBlocking(False)

    # Yolo specific parameters

    detectionNetwork.setNumClasses(1)

    detectionNetwork.setCoordinateSize(4)

    #detectionNetwork.setNumInferenceThreads(2)

    #detectionNetwork.setIouThreshold(0.5)

    # Linking

    camRgb.preview.link(detectionNetwork.input)

    #if syncNN:

    detectionNetwork.passthrough.link(xoutRgb.input)

    #else:

    # camRgb.preview.link(xoutRgb.input)

    detectionNetwork.out.link(xoutNN.input)

    #detectionNetwork.outNetwork.link(nnNetworkOut.input)

    print(1)

    # Connect to device and start pipeline

    with dai.Device(pipeline) as device:

    print(2)

    # Output queues will be used to get the rgb frames and nn data from the outputs defined above

    previewQueue = device.getOutputQueue(name="rgb", maxSize=4, blocking=False)

    detectionNNQueue = device.getOutputQueue(name="detections", maxSize=4, blocking=False)

    #networkQueue = device.getOutputQueue(name="nnNetwork", maxSize=4, blocking=False)

    startTime = time.monotonic()

    counter = 0

    fps = 0

    color = (0, 150, 255)

    #printOutputLayersOnce = True

    while True:

    print("loop")

    inPreview = previewQueue.get()

    inDet = detectionNNQueue.get()

    #inNN = networkQueue.get()

    #if printOutputLayersOnce:

    # toPrint = 'Output layer names:'

    # for ten in inNN.getAllLayerNames():

    # toPrint = f'{toPrint} {ten},'

    # print(toPrint)

    # printOutputLayersOnce = False

    frame = inPreview.getCvFrame()

    counter += 1

    current_time = time.monotonic()

    if (current_time - startTime) > 1:

    fps = counter / (current_time - startTime)

    counter = 0

    startTime = current_time

    detections = inDet.detections

    # If the frame is available, draw bounding boxes on it and show the frame

    height, width = frame.shape[:2]

    for detection in detections:

    # Denormalize bounding box

    x1 = int(detection.xmin * width)

    x2 = int(detection.xmax * width)

    y1 = int(detection.ymin * height)

    y2 = int(detection.ymax * height)

    try:

    label = labelMap[detection.label]

    except IndexError:

    label = f'Label {detection.label}'

    cv2.putText(frame, label, (x1 + 10, y1 + 20), cv2.FONT_HERSHEY_TRIPLEX, 0.5, color)

    cv2.putText(frame, f"{detection.confidence*100:.2f}%", (x1 + 10, y1 + 40), cv2.FONT_HERSHEY_TRIPLEX, 0.5, color)

    cv2.rectangle(frame, (x1, y1), (x2, y2), color, 2)

    cv2.putText(frame, f"NN fps: {fps:.2f}", (2, height - 4), cv2.FONT_HERSHEY_TRIPLEX, 0.5, color)

    cv2.imshow("rgb", frame)

    if cv2.waitKey(1) == ord('q'):

    break

    cv2.destroyAllWindows()

    time.sleep(0.01)

    • jakaskerl
      Hi, I found one problem, when configuration range 10-100Mb camaera work good. If I put 1Gb, then momentaly get error.
      But 100MB, give only 17 FPS, not 26 FPS in 1Gb mode.

    • jakaskerl
      I get that info from raspberry

      "pi@pi:~$ ip rout

      default via 192.168.1.254 dev wlan0 proto dhcp metric 600

      default via 169.254.1.1 dev eth0 proto static metric 20100

      169.254.0.0/16 dev eth0 proto kernel scope link src 169.254.1.250 metric 100

      192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.104 metric 600 "

      Can be that problem if i don't have last line?

      • jakaskerl
        I open port but still it didn't help.
        On third script run, model start work, but with out mikrotik, run always.
        (Also, seems strange to me (perhaps it's ok), you save set the gateway to 1.254) - i use different input internet router, but it didn't help.

        BR,
        Edmunds

        • Hello!
          I connect my camera to raspberry with model and use MIKROTIK router like switch (PTP Bridge AP). But every secondary run, get error and cant normally start my python model.
          If i connect Lan cable to Raspberry(with out router) all work fine.
          I have RB951G-2HnD router.
          If some one configurate it, can help to reconfig it? Or u get some idea to FIX it?
          Because with Archer(TP-link) similar, didn't have any problem.

          • jakaskerl
            HI!
            With Wi-fi router TP-link, with changed static IP adress 169.254.1.1. And in that configuration, when I connect OaK to router and Pi same connect to router, works fine.

          • With Wi-fi touter, all working fine, but when connect device-device, get problem.

          • Hi, i change Pi config to:

            1. sudo nano /etc/dhcpcd.conf
              2.

            interface eth0
            static ip_address=169.254.1.101/16

            1. sudo service dhcpcd restart

            And try connect OaK-1 POE to Pi, but cant see OaK 169.254.1.222. What can be the problem?