欢迎光临散文网 会员登陆 & 注册

python重启就会报错,也是没谁了

2020-03-10 16:23 作者:一心想当网红的李老师  | 我要投稿

# -*- coding: utf-8 -*-

"""

Created on Tue Mar 10 14:04:43 2020


@author: liyan

"""

import tkinter

from tkinter import *

from PIL import Image,ImageTk

from tkinter.filedialog import askopenfilename

import time

import CV2

import tkinter as tk

import array

import numpy as np



data=[]



def getposBgr(event, x, y, flags, param):

    if event==CV2.EVENT_LBUTTONDOWN:

        print("Bgr is", img[y, x])

        data=img[y, x]

        print(data)

        print(data[0])

        f=open('data.txt','a')

        info=str(data[0])+";"+str(data[1])+";"+str(data[2])+"\n"

        f.write(info)

        f.close()


      

top=tkinter.Tk()

file_path=askopenfilename()

img = CV2.imread(file_path)

print(img)

HSV = CV2.cvtColor(img, CV2.COLOR_BGR2HSV)

CV2.imshow('image', img)

CV2.setMouseCallback("image", getposBgr)

CV2.waitKey(0)

CV2.destroyAllWindows()

top.mainloop() 


python重启就会报错,也是没谁了的评论 (共 条)

分享到微博请遵守国家法律