I want to take a screenshot of whole screen in python which is doable(feasible) to me. But if i want to take screenshot of a desired clipped area like the picture shown below means first of all, user should select(clip) a region using mouse pointer and then take screenshot of that area. So i want to say that how to clip a portion of an image in a clipboard?
NOTE: I have found some packages like "clipboard" and "pyperclip" but i couldn't understand how to clip an image? Help me
I got a code but it shows to clip only text. What modifications should be made in it to clip a desired area of an image.
import clipboard
clipboard.copy("abc")
text = clipboard.paste()
print(text)
I would find a python module that allowed you to edit image files, or use a binding to an external program. A tool like pyperclip will enable you to get at the image in python, you will then have to edit the image yourself using a module or something else.
Related
I want to extract certain part from the image
I am running Python 3.9.12 with CV2 4.6.0 on Ubuntu 22.04.1 LTS
(From) The original pic:
https://ibb.co/RcZ7ntL
(then) The pic want to locate(I want to extract the red part only):
https://ibb.co/dGBfqXx
(the desire pic/output) : https://ibb.co/j5h501f
I've tried searching for a solution on StackOverflow, but I didn't find anything remotely similar. And I search that most of the tutorial is teaching finding the same image in image.
In case someone doesn't want to load too many pics, I put them as link instead.
so my main issue is that not sure how to cut them into the picture I want
this is after I manual cut to the part I want, then I can do OCR recognize image to text
the desire pic/output : https://ibb.co/j5h501f
the pic I success detect the image to text: https://ibb.co/mv9WTpW
I come up a idea [solution A]
that using openCV bounding box cut every sticker separated https://ibb.co/1Q9DnLJ
cause every line is fixed distance (ex: CA74C8), then give cv the correct scale to cut
how to make [solution A] step 1 work? I have tried for half of a day but still stock on this, I need a hand thanks
You can do the reverse task:
run your OCR first, since it will find all texts in the image for you.
If you you tesseract, it will send you all the text AND the locations/boxes where the text is found.
like here:
is there a way to get information about the zoomed section in python cv2 ?
when using opencv in python (import cv2)
then using cv2.imshow('windowname', imgnparray)
then when i hover over the image and use the scroll wheel i can zoom into the image, in python can i somehow get information about the zoomed area?
in my example the zoom would be around 3 times zoomed in and 0.5 offset left and 0.25 offset top
That's currently not possible.
To get this information, you would need to modify OpenCV's source code. You could open an issue about this, requesting the feature.
The relevant values can be found in the variable positionCorners in the file modules/highgui/src/window_QT.cpp.
I am viewing the image on the screen using open cv in python. But the image which I opened with the code is halfway on the screen. But I want you to look full screen. How can I do that? Could you help?
You can use this:
cv2.namedWindow("WindowName",cv2.WINDOW_FULLSCREEN)
cv2.imshow("WindowName",output_image)
cv2.waitKey(0)
First you have to create a namedWindow with full screen property. Property you should use is cv2.WINDOW_FULLSCREEN from documentation.
You can create a window manually and resize it. For example:
cv2.namedWindow("Image",WINDOW_NORMAL);
cv2.resizeWindow("Image",1366,768); //Enter your size
cv2.imshow("Image",frame);
If the image is not display on a full screen, then resize image using command cv2.resize()! Good luck!
I already can add text to an image using Pillow in Python. However, I want to know how I can add formatted text. In particular, I want to add a box of text to an image such that the text is center justified.
If this isn't possible using Pillow, I am open to other image manipulation libraries (including in other languages) that make overlaying formatted text on images easier.
refer to the function in this link - http://pillow.readthedocs.io/en/3.1.x/reference/ImageDraw.html#PIL.ImageDraw.PIL.ImageDraw.Draw.text
the first argument is location. you can give it based on the size of your image on which you want to add text.
Here is a simple library which does the job of text alignment using PIL:
https://gist.github.com/turicas/1455973
I want to sift through a collection of video files looking for a certain logo, and then record the 10-15 seconds leading up to it. I can recognize the logo by checking a certain pixel color.
How would you do it? Is there software or a python package that allows me to extract those chunks of files and write those into a new video?
What i have done so far:
I have found a library that is able to convert a video into a series of BMPs. What the programs. Its called pyMedia: http://pymedia.org/tut/src/dump_video.py.html and the reverse: http://pymedia.org/tut/src/make_video.py.html
So thats pretty neat. However its only working with python 2.3, not with python 3.
Seems like :
d= e.encode( yuvFrame )
fw.write( d )
writes a BMP file. So how do i look in for a certain colored pixel or logo in a BMP file and put it together? Thats what i cant get working somehow. Maybe someone can help me with this.
edit:
let me show you what i have done so far:
from PIL import Image
im = Image.open("bride.bmp")
i=0
width= 10
height = 10
top= 461
box = (left, top, left+width, top+height)
croppy=im.crop(box)
if (mycolor in croppy.getcolors()):
print "Logo found"
My logo has a certain color, so this looks for the pixel and prints logo found if the pixelcolor is found. Didnt really want to make a classifier for that.
Using perhaps OpenCV or another package -- essentially, you want to train a classifier to identify your logo and then feed it the bitmaps from your video. When it identifies the logo, then you trigger the code which captures the previous 15s of video.
This is a very detailed answer about how one might do this in Python General approach to developing an image classification algorithm for Dilbert cartoons