Ask Your Question

clara's profile - activity

2019-10-08 13:32:53 -0500 received badge  Famous Question (source)
2018-09-22 09:14:13 -0500 received badge  Notable Question (source)
2018-07-18 04:20:40 -0500 received badge  Popular Question (source)
2018-01-26 06:50:19 -0500 received badge  Supporter (source)
2018-01-26 05:44:34 -0500 marked best answer TypeError: img is not a numpy array, neither a scalar

I have data similar to the following :

10-0 = [
    [1915, 387, 1933, 402],
    [3350, 387, 3407, 391],
    [842, 505, 863, 521],
 ]

10-0 being the credentials of an image(to find the path) and the values inside are coordinates of a box or rectangle each, the formula i'm working on is cv2.rectangle(img, (x1, y1), (x2, y2), (255,0,0), 2) , note that 10-0 is the key of one element of a dictionary.

My code :

import cv2
    for key in my_dict:
        folder_blueprint = re.findall(r'\d+', key)
        img = PATH_TO_SOURCE+str(folder_blueprint[0])+'-'+str(folder_blueprint[1])+'.png'
        for line in key:
            line_number = 0
            cv2.rectangle(img,( my_dict[key][line_number][0],my_dict[key][line_number][1]),(my_dict[key][line_number][2],my_dict[key][line_number][3]),(255,0,0),2)
            # cv2.imread(img)
            line_number = line_number + 1
        cv2.imwrite(FULL_PATH_TO_DESTINATION, img)
        cv2.imshow(FULL_PATH_TO_DESTINATION, img)
        k = cv2.waitKey(0)  # 0==wait forever

What i finally want is the image with red boxes around the regions of interest in a new destination folder leaving the original image intact. And i have referred to similar questions on here with the same error message but they weren't helpful to my case.

2018-01-26 05:44:34 -0500 received badge  Scholar (source)
2018-01-26 05:10:14 -0500 commented answer TypeError: img is not a numpy array, neither a scalar

Then i kept only cv2.imwrite(FULL_PATH_TO_DESTINATION, img) deleted the 2 lines under, ran without errors but there was

2018-01-26 05:08:01 -0500 commented answer TypeError: img is not a numpy array, neither a scalar

Then i kept only cv2.imwrite(FULL_PATH_TO_DESTINATION, img) deleted the 2 lines under, ran without errors but there was

2018-01-26 05:06:56 -0500 commented answer TypeError: img is not a numpy array, neither a scalar

Ok, i fixed that part then strangely for someone using opencv for the first time i got this error `OpenCV Error: Unspeci

2018-01-26 04:52:09 -0500 commented answer TypeError: img is not a numpy array, neither a scalar

Adjusted that part then got the following error error: (-2) could not find a writer for the specified extension in funct

2018-01-26 04:38:58 -0500 asked a question TypeError: img is not a numpy array, neither a scalar

TypeError: img is not a numpy array, neither a scalar I have data similar to the following : 10-0 = [ [1915, 387, 1