openCV 图片的处理

Posted yugengde

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了openCV 图片的处理相关的知识,希望对你有一定的参考价值。

将 base64为的字符串转换为图片

data = ‘‘‘/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0a
HBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIy
MjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAAeAUADASIA
AhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQA
AAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3
ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWm
p6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEA
AwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSEx
BhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElK
U1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3
uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD12iii
mAUUUUAFFFFABRRRQAUxpokljieVFkkzsQsAWx1wO+KV3SONpJGVUUEszHAAHc1yF1qLyeITLa3V
vfi0RpIUxliz4DRps+98oJDYIGfm9QJAdjRXCSatq2nXbR3FxcQMHgeRZYxKoQjEj8Z+XfjAUjrg
YPTsdNnlutMtriYp5ksSyHYpAGRnGCT602gLVFFFIAooooAKKKKACiiigAooooAKKKKACiiigAoo
ooAq31/Fp8IklWVyxKxxwxl3dsE4AHsD14rnLvxJf7ZreNLa1mcAxNcOBKm4javkoXZmwQc4HuOO
dbxPax3OgXBlhSZYds5RztyEIZgCBkEqGGR61xQn1JZPIhgvElzK4trYJZxb04dV2EmfBGOCGwPf
jGpJp2A9IgmWeFZF4zwVyCVI4KnBIyDkHnqKkrnPCN1G9vc2cXkeTC4khFvJvRY3GQuT827IbIYA
8+mAOjrSLurgFFFFUAUUUUAFFFFABRRRQAUUUUAFFFFABRRRQAUUUUAMmaRIJHij82RVJVN23ccc
DPbNcxJFdWVpeTzQXzz3lxIwht4klYx4wqyEqwAHTAJ4bvzjqqKAOGghMeqSW1nLbfabpVKKk7xI
pVRlXWPaQw+bqADnPykFT3NRS21vPJHJNBFI8RzGzoCUPqM9Og/KpabYBRRRSAKKKKACiiigAooo
oAKKKKACiiigAooooAKKKKAKeq2017pdxaQOiPOnllnBIVW4Y4HfaTj3xTYNLghuJptqkvcm5QKN
uxjGEPTrn5j/AMC/Gr1FKyvcCvbWNnZbvslpBBvxu8qMLux0zj6mrFFFMAooooAKKKKACiiigAoo
ooA//9k=‘‘‘

img_data = base64.b64decode(data)
with open(img.png, wb) as f:
    f.write(img_data)

这样就可以在当前目录下生成一张名为img的图片啦

以上是关于openCV 图片的处理的主要内容,如果未能解决你的问题,请参考以下文章

图片处理-opencv-3.图像缩放、旋转、翻转、平移

OpenCV+Python实现将车牌数字分割为单个的字符图片

pyhton—opencv直线检测(HoughLines)找到最长的一条线

pyhton—opencv直线检测(HoughLines)找到最长的一条线

手把手:使用OpenCV进行面部合成— C++ / Python

opencv怎么截取视频图片