python: "read out" the contrast of a JPG image

asked 2019-02-19 02:45:53 -0500

Felix92 gravatar image

updated 2019-02-21 06:23:47 -0500

Hello, I'm new to OpenCV,

short to the problem:

I have an object in which a JPG image is stored to be more specific a slide with black text and white background now I would like to show if there is enough space on the slide at the bottom right of a video stream.

My idea is to read out the contrast in the image and then subtract the value of the entire length of the image to see if there is enough space ... if so then the video should be displayed otherwise.

first question:

would that be possible with OpenCV?

second question:

if so, how should I go there the best?

Thank you very much



from wand.image import Image as wa
from slide import Slide

class Presentation:
    """Class that divides a PDF into individual images and converts them to jpg"""
    def __init__(self):
        """Constructor of the class"""
        print('Image erstellt')

    def convert(self, path, filename):
        """a method that takes a path and a PDF file, converts them to JPG, and then saves the individual images"""
        pdf = wa(file=path + filename, resolution=300)
        pdf_images = pdf.convert("jpeg")
        page_number = 1
        for img in pdf_images.sequence:
            page = wa(image=img)
            slide = []
            slide.append(Slide(page_number, page))
            page_number += 1

object: This object is the starting point for OpenCV

class Slide:
    """Constructor that saves the current page and page number"""
    def __init__(self, page_number, page):
        self.page_number = page_number = page
edit retag flag offensive close merge delete


i removed your (useless here) screenshots.

please EDIT your question again, and add TEXT versions of your code snippets, so ppl can quote you, try your code, it can be indexed for search, etc. thank you.

berak gravatar imageberak ( 2019-02-19 02:48:27 -0500 )edit

can you try to highlight, how or where this is relevant to opencv (a computer-vision library) ?

berak gravatar imageberak ( 2019-02-21 04:55:19 -0500 )edit

I've not understand why you use the contrast value and then subtract the length of the image, can you please clarify what you want to do? Please be more precise. You have those slides (call it images from now since in OpenCV you threat them as images) and you want to check if there is enough space in the bottom right for adding a video stream directly in the slide? Sorry maybe I've misunderstand but your question seems not clear to me. With OpenCV you can do almost everything on images and videos, but you have to understand if this is the quickest way for your need.

HYPEREGO gravatar imageHYPEREGO ( 2019-02-21 09:37:47 -0500 )edit