My code is working on the robot when I plugged the camera to the pc and robot is just working flawless but when I upload the same code into the RPi3B+ code is outputting same result
here is my code that positioning the robot to contours center
import cv2
import logging
import numpy as np
from networktables import NetworkTables
CAMERA CONF STUFF
kam = cv2.VideoCapture(1)
kam.set(cv2.CAP_PROP_FRAME_WIDTH, 180)
kam.set(cv2.CAP_PROP_FRAME_HEIGHT, 180)
kam.set(cv2.CAP_PROP_AUTO_EXPOSURE, 0)
kam.set(cv2.CAP_PROP_EXPOSURE, -15.0)
NETWORKING STUFF
logging.basicConfig(level=logging.DEBUG)
ip = “10.60.38.2”
NetworkTables.initialize(server=ip)
table = NetworkTables.getTable(“idris_ustam”)
HYPER PARAMETERS
lower = np.array([65, 100, 100])
upper = np.array([85, 255, 255])
x = 0
y = 0
w = 0
h = 0
cY = 0
cX = 0
ekranY = 0
ekranX = 0
alan = 0
while True:
_, ret = kam.read()
hsv = cv2.cvtColor(ret, cv2.COLOR_BGR2HSV)
elonmask = cv2.inRange(hsv, lower, upper)
_, contours, _ = cv2.findContours(elonmask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
if len(contours) > 0:
for c in contours:
x, y, w, h = cv2.boundingRect(c)
cY = y + (h / 2)
cX = x + (w / 2)
cY = int(cY)
cX = int(cX)
alan = w * h
else:
cX = 0
table.putNumber("cX", cX)
table.putNumber("ALAN", alan)
print(cX)