Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pillow update image

#!/usr/local/bin/python3
import numpy as np
import cv2

def sin2d(x,y):
    """2-d sine function to plot"""
    return np.sin(x) + np.cos(y)

def getFrame():
    """Generate next frame of simulation as numpy array"""

    # Create data on first call only
    if getFrame.z is None:
        xx, yy = np.meshgrid(np.linspace(0,2*np.pi,w), np.linspace(0,2*np.pi,h))
        getFrame.z = sin2d(xx, yy)
        getFrame.z = cv2.normalize(getFrame.z,None,alpha=0,beta=1,norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_32F)

    # Just roll data for subsequent calls
    getFrame.z = np.roll(getFrame.z,(1,2),(0,1))
    return getFrame.z

# Frame size
w, h = 640, 480

getFrame.z = None

while True:
       
    # Get a numpy array to display from the simulation
    npimage=getFrame()

    cv2.imshow('image',npimage)
    cv2.waitKey(1)
Comment

pillow update image

#!/usr/local/bin/python3
import numpy as np
import cv2

def sin2d(x,y):
    """2-d sine function to plot"""
    return np.sin(x) + np.cos(y)

def getFrame():
    """Generate next frame of simulation as numpy array"""

    # Create data on first call only
    if getFrame.z is None:
        xx, yy = np.meshgrid(np.linspace(0,2*np.pi,w), np.linspace(0,2*np.pi,h))
        getFrame.z = sin2d(xx, yy)
        getFrame.z = cv2.normalize(getFrame.z,None,alpha=0,beta=1,norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_32F)

    # Just roll data for subsequent calls
    getFrame.z = np.roll(getFrame.z,(1,2),(0,1))
    return getFrame.z

# Frame size
w, h = 640, 480

getFrame.z = None

while True:
       
    # Get a numpy array to display from the simulation
    npimage=getFrame()

    cv2.imshow('image',npimage)
    cv2.waitKey(1)
Comment

pillow update image

#!/usr/local/bin/python3
import numpy as np
import cv2

def sin2d(x,y):
    """2-d sine function to plot"""
    return np.sin(x) + np.cos(y)

def getFrame():
    """Generate next frame of simulation as numpy array"""

    # Create data on first call only
    if getFrame.z is None:
        xx, yy = np.meshgrid(np.linspace(0,2*np.pi,w), np.linspace(0,2*np.pi,h))
        getFrame.z = sin2d(xx, yy)
        getFrame.z = cv2.normalize(getFrame.z,None,alpha=0,beta=1,norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_32F)

    # Just roll data for subsequent calls
    getFrame.z = np.roll(getFrame.z,(1,2),(0,1))
    return getFrame.z

# Frame size
w, h = 640, 480

getFrame.z = None

while True:
       
    # Get a numpy array to display from the simulation
    npimage=getFrame()

    cv2.imshow('image',npimage)
    cv2.waitKey(1)
Comment

pillow update image

#!/usr/local/bin/python3
import numpy as np
import cv2

def sin2d(x,y):
    """2-d sine function to plot"""
    return np.sin(x) + np.cos(y)

def getFrame():
    """Generate next frame of simulation as numpy array"""

    # Create data on first call only
    if getFrame.z is None:
        xx, yy = np.meshgrid(np.linspace(0,2*np.pi,w), np.linspace(0,2*np.pi,h))
        getFrame.z = sin2d(xx, yy)
        getFrame.z = cv2.normalize(getFrame.z,None,alpha=0,beta=1,norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_32F)

    # Just roll data for subsequent calls
    getFrame.z = np.roll(getFrame.z,(1,2),(0,1))
    return getFrame.z

# Frame size
w, h = 640, 480

getFrame.z = None

while True:
       
    # Get a numpy array to display from the simulation
    npimage=getFrame()

    cv2.imshow('image',npimage)
    cv2.waitKey(1)
Comment

pillow update image

#!/usr/local/bin/python3
import numpy as np
import cv2

def sin2d(x,y):
    """2-d sine function to plot"""
    return np.sin(x) + np.cos(y)

def getFrame():
    """Generate next frame of simulation as numpy array"""

    # Create data on first call only
    if getFrame.z is None:
        xx, yy = np.meshgrid(np.linspace(0,2*np.pi,w), np.linspace(0,2*np.pi,h))
        getFrame.z = sin2d(xx, yy)
        getFrame.z = cv2.normalize(getFrame.z,None,alpha=0,beta=1,norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_32F)

    # Just roll data for subsequent calls
    getFrame.z = np.roll(getFrame.z,(1,2),(0,1))
    return getFrame.z

# Frame size
w, h = 640, 480

getFrame.z = None

while True:
       
    # Get a numpy array to display from the simulation
    npimage=getFrame()

    cv2.imshow('image',npimage)
    cv2.waitKey(1)
Comment

pillow update image

#!/usr/local/bin/python3
import numpy as np
import cv2

def sin2d(x,y):
    """2-d sine function to plot"""
    return np.sin(x) + np.cos(y)

def getFrame():
    """Generate next frame of simulation as numpy array"""

    # Create data on first call only
    if getFrame.z is None:
        xx, yy = np.meshgrid(np.linspace(0,2*np.pi,w), np.linspace(0,2*np.pi,h))
        getFrame.z = sin2d(xx, yy)
        getFrame.z = cv2.normalize(getFrame.z,None,alpha=0,beta=1,norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_32F)

    # Just roll data for subsequent calls
    getFrame.z = np.roll(getFrame.z,(1,2),(0,1))
    return getFrame.z

# Frame size
w, h = 640, 480

getFrame.z = None

while True:
       
    # Get a numpy array to display from the simulation
    npimage=getFrame()

    cv2.imshow('image',npimage)
    cv2.waitKey(1)
Comment

pillow update image

#!/usr/local/bin/python3
import numpy as np
import cv2

def sin2d(x,y):
    """2-d sine function to plot"""
    return np.sin(x) + np.cos(y)

def getFrame():
    """Generate next frame of simulation as numpy array"""

    # Create data on first call only
    if getFrame.z is None:
        xx, yy = np.meshgrid(np.linspace(0,2*np.pi,w), np.linspace(0,2*np.pi,h))
        getFrame.z = sin2d(xx, yy)
        getFrame.z = cv2.normalize(getFrame.z,None,alpha=0,beta=1,norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_32F)

    # Just roll data for subsequent calls
    getFrame.z = np.roll(getFrame.z,(1,2),(0,1))
    return getFrame.z

# Frame size
w, h = 640, 480

getFrame.z = None

while True:
       
    # Get a numpy array to display from the simulation
    npimage=getFrame()

    cv2.imshow('image',npimage)
    cv2.waitKey(1)
Comment

pillow python update image

# It's a pain, better to use pygame or openCV
# Search "Opencv for python"
Comment

pillow update image

#!/usr/local/bin/python3
import numpy as np
import cv2

def sin2d(x,y):
    """2-d sine function to plot"""
    return np.sin(x) + np.cos(y)

def getFrame():
    """Generate next frame of simulation as numpy array"""

    # Create data on first call only
    if getFrame.z is None:
        xx, yy = np.meshgrid(np.linspace(0,2*np.pi,w), np.linspace(0,2*np.pi,h))
        getFrame.z = sin2d(xx, yy)
        getFrame.z = cv2.normalize(getFrame.z,None,alpha=0,beta=1,norm_type=cv2.NORM_MINMAX, dtype=cv2.CV_32F)

    # Just roll data for subsequent calls
    getFrame.z = np.roll(getFrame.z,(1,2),(0,1))
    return getFrame.z

# Frame size
w, h = 640, 480

getFrame.z = None

while True:
       
    # Get a numpy array to display from the simulation
    npimage=getFrame()

    cv2.imshow('image',npimage)
    cv2.waitKey(1)
Comment

PREVIOUS NEXT
Code Example
Python :: how to build a compiler in python 
Python :: video in python without cv2 
Python :: multiple channel creating command in discord.py 
Python :: pool.map multiple arguments 
Python :: urlib3 json 
Python :: separate alphanumeric list 
Python :: why does async def not work python 
Python :: capitalise.texts 
Python :: auto clipping path when upload image using python 
Python :: scipy random seed 
Python :: python inverse dict with repeating values 
Python :: subtract 2 datetime objects django 
Python :: python scrapy 
Python :: flask get summernote text 
Python :: python web app with redis github 
Python :: python - concatenate if null 
Python :: how to change the type of a values in list from str to object python 
Python :: Logistic Regression with a Neural Network mindset python example 
Python :: comment enleve les chiffre duplice d une liste python 
Python :: nlp.Defaults.stop_words.add spacy 
Python :: Faster way to find list of unique elements in a list 
Python :: legend matplotlib twinx 
Python :: removing stop words in python 
Python :: matplotlib FiveThirtyEight horizontal graph 
Python :: polycarp and coins codeforces solution 
Python :: django force download file 
Python :: mechanize python LE #3 
Python :: converting string key to int py 
Python :: how to separate audio frequencies python 
Python :: .format() 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =