[Python] functions have different types, the output array type must be explicitly specified in...

Discussão em 'Python' iniciado por Stack, Maio 10, 2025.

  1. Stack

    Stack Membro Participativo

    i got confused about seeing the error, can you please help me to sort this issue.

    My python code :-

    # Get image ready for feeding into model
    #small_img = imresize(image, (80, 160, 3))
    small_img = resize(image, (80,160), order=3)

    small_img = np.array(small_img)
    small_img = small_img[None,:,:,:]

    # Make prediction with neural network (un-normalize value by multiplying by 255)
    prediction = model.predict(small_img)[0] * 255

    # Add lane prediction to list for averaging
    lanes.recent_fit.append(prediction)
    # Only using last five for average
    if len(lanes.recent_fit) > 5:
    lanes.recent_fit = lanes.recent_fit[1:]

    # Calculate average detection
    lanes.avg_fit = np.mean(np.array([i for i in lanes.recent_fit]), axis = 0)

    # Generate fake R & B color dimensions, stack with G
    blanks = np.zeros_like(lanes.avg_fit).astype(np.uint8)
    lane_drawn = np.dstack((blanks, lanes.avg_fit, blanks))

    # Re-size to match the original image
    #lane_image = imresize(lane_drawn, (720, 1280, 3))
    lane_image = resize(lane_drawn, (720,1280), order=3)

    # Merge the lane drawing onto the original image
    result = cv2.addWeighted(image, 1, lane_image, 1, 0)

    return result


    when i run this code im getting the error like below.


    result = cv2.addWeighted(image, 1, lane_image, 1, 0) cv2.error: OpenCV(4.6.0) /Users/runner/work/opencv-python/opencv-python/opencv/modules/core/src/arithm.cpp:674: error: (-5:Bad argument) When the input arrays in add/subtract/multiply/divide functions have different types, the output array type must be explicitly specified in function 'arithm_op'
    ​

    Can anyone guide me where im doing wrong ?

    Continue reading...

Compartilhe esta Página