I've tried everything from other questions but nothing seems to work. It’s installed on this computer, it’s just I can’t import it!
Here’s what I wrote:
from PIL import Image
#Open image using Image module
im = Image.open("/home/****/Pictures/Screenshot from 2021-08-03 18-21-59.png")
#Show actual Image
im.show()
Related
my plan is to make a bot that will answer a bot on messenger
the messenger bot messages are randomized number or a math questionaire bot
so i want to make a bot that will answer the messenger bots qustions
i made a code like this:
import pyautogui
import pytesseract
from PIL import Image
i want to take screenshot every 10 seconds
pyautogui.sleep(2)
sleep for two seconds to give me time to switch from pycharm to messenger
pyautogui.screenshot('x_value.png', confidence=0.8)
img = Image.open('x_value.png')
img = pytesseract.image_to_string(img)
print(img)
here is the taken screenshot by my bot
here is the result:
Tee oxHj
i tried resizing the image using tuple but I still get the wrong result....i hope ypu guys help me so i can improve my skills....thank you
It worked when I inverted the image. But I wasn't able to use .png format so I tried in .jpg format and it worked. You can try this.
import pytesseract
from PIL import Image, ImageOps
img = Image.open('f1.jpg')
img = ImageOps.invert(img)
img = pytesseract.image_to_string(img)
print(img)
Hope I helped.
I have been using PubChem API to convert Chemical smiles to the structure but still have an error.
Here is my google colab I try with PIL image plus TKinter
https://colab.research.google.com/drive/1TE9WxXwaWKSLQzKRQoNlWFqztVSoIxB7
My desired output should be in structure format like this
https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/O=C(N1C=CN=C1)N2C=CN=C2/PNG?record_type=2d&image_size=large
Download and display in a Jupyter Notebook
from urllib.request import urlretrieve
from IPython.display import Image
smiles = 'NC1=NC(C)=C(C2=CC=C(S(=O)(C)=O)C(F)=C2)S1'
urlretrieve('https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/'+smiles+'/PNG', 'smi_pic.png')
p = Image(filename='smi_pic.png')
p
Output
I am experimenting with openCV and object detection using Python 3.6 on Ubuntu Linux 18.04. I have found this simple Python code at this website that claims to accomplish image detection.
import cv2
import matplotlib.pyplot as plt
import cvlib as cv
from cvlib.object_detection import draw_bbox
im = cv2.imread('/home/gerry/Pictures/guyonstreet.jpg')
bbox, label,conf = cv.detect_common_objects(im)
output_image = draw_bbox(im, bbox, label, conf)
plt.imshow(output_image)
plt.show()
I have installed the necessary libraries without issue as shown on the website. I can run the code without errors. Unfortunately the resulting image fails to show the expected bounding box identifying the object. Below is a screenshot of what the code returned when I ran the experiment on a person. I get similar results when I use an image of fruit.
Why is my code not returning the bounding box identifying the object?
I have seen this question before , but the solutions given did not help. I saved it with.py extension before running it, as well as checked the auto and Python build system. Nothing works.
I am simply inserting an image, and changing it to gray. It is for an AI project.
This is my code:
import cv2
import numpy as np
image = cv2.imread('test_image.jpg')
lane_image = np.copy(image)
gray = cv2.cvtColor(lane_image, cv2.COLOR_RGB2GRAY)
cv2.imshow('result', gray)
cv2.waitKey(0)
I have been playing around with images in Python, just trying to understand how things work basically. I have noticed something odd and was wondering if anyone else could explain it.
I have an image 'duck.jpg' -
If I look at the properties I can see that it is a jpg image.
However, after importing into python using the follwoing convoluted way:
from PIL import Image
import io
with open('duck.jpg', 'rb') as f:
im = Image.open(io.BytesIO(f.read()))
f.close()
I get the following output after calling
im.format
'PNG'
Is there some sort of automatic conversion going on?