Open pixkk opened 4 months ago
try: buf = fig.canvas.tostring_rgb() except AttributeError: fig.canvas.draw() buf = fig.canvas.tostring_rgb() cols, rows = fig.canvas.get_width_height() img_array = np.frombuffer(buf, dtype=np.uint8).reshape(rows, cols, 4) result = cv2.cvtColor(img_array, cv2.COLOR_RGB2BGR) plt.close() return result
have a try
File prompt.py: