Home Python shows error "name 'resized' is not defined" on compiling the following code
Reply: 0

Python shows error "name 'resized' is not defined" on compiling the following code

user1243 Published in May 26, 2018, 9:40 pm

I'm trying to implement line detection on python using raspberry pi 3 and picam

import picamera
import picamera.array
import time
import cv2
import numpy as np

#Initialize camera
camera = picamera.PiCamera()
camera.resolution = (640,480)
rawCapture = picamera.array.PiRGBArray(camera)
#Let camera warm up

#Capture image
camera.capture(rawCapture, format="bgr")
img = rawCapture.array

#Convert to Grayscale
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)

#Blur image to reduce noise
blurred = cv2.GaussianBlur(gray, (9, 9), 0)

#Perform canny edge-detection
edged = cv2.Canny(blurred, 50, 150)

#Perform hough lines probalistic transform
lines = cv2.HoughLinesP(edged,1,np.pi/180,10,80,1)

#Draw lines on input image
if(lines != None):
    for x1,y1,x2,y2 in lines[0]:

cv2.imshow("line detect test", img) 

The following error is displayed:

Traceback (most recent call last): File "/home/pi/picam lane detection.py", line 33, in cv2.line(resize,(x1,y1),(x2,y2),(0,255,0),2) NameError: name 'resize' is not defined

Please help me figure out the issue.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.32202 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO