This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (!fork()) { | |
| cv::imshow("debug", frame_image); | |
| cv::waitKey(0); | |
| exit(0); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| my_tuple = ('p','r','o','g','r','a','m','i','z') | |
| print("og forward:") | |
| print("og: ",my_tuple[2:4]) | |
| print("og: ",my_tuple[-7:4]) | |
| print("og: ",my_tuple[-7:-5]) | |
| print("og: ",my_tuple[2:-5]) | |
| print("og backwards (go):") | |
| print("go: ",my_tuple[3:1:-1]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Method 1, pythonic | |
| img_res = np.zeros(image.shape, np.uint8) #create the image | |
| img_res[:, :] = (0, 0, 200) #color it red | |
| idx = (mask != 0) | |
| img_res[idx] = image[idx] | |
| #Method 2 OpenCV | |
| img_red = np.zeros(image.shape, np.uint8) #create the image | |
| img_red[:, :] = (0, 0, 200) #color it red | |
| fg = cv2.bitwise_and(image, image, mask=mask) #isolate the segmented region |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cap = cv2.VideoCapture('/opt/home/garybradski/data/matte_this/shot02/Tornado.mp4') | |
| length = int(cap.get(cv2.cv.CV_CAP_PROP_FRAME_COUNT)) | |
| print "len Tornado = ", length | |
| cv2.namedWindow('Tornado', cv2.WINDOW_NORMAL) | |
| cv2.resizeWindow('Tornado',960,540) | |
| # seek | |
| assert cap.set(cv2.cv.CV_CAP_PROP_POS_FRAMES, 8000) | |
| n = 0 | |
| wait_key = 30 | |
| while True: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import argparse | |
| import logging | |
| parser.add_argument('--loglevel', help='Logging level: NONE, DEBUG 10, INFO 20, WARNING 30, ERROR 40, CRITICAL 50. Default: OFF 100', type=str, default='WARNING' ) | |
| args = parser.parse_args() | |
| logging.basicConfig() | |
| logger = logging.getLogger() | |
| if(args.loglevel == 'OFF'): logger.setLevel(100) | |
| elif(args.loglevel == 'DEBUG'): logger.setLevel(logging.DEBUG) | |
| elif(args.loglevel == 'INFO'): logger.setLevel(logging.INFO) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import cv2 | |
| # Read the images | |
| foreground = cv2.imread("puppets.png") | |
| background = cv2.imread("ocean.png") | |
| alpha = cv2.imread("puppets_alpha.png") | |
| # Convert uint8 to float | |
| foreground = foreground.astype(float) | |
| background = background.astype(float) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void alphaBlend(Mat& foreground, Mat& background, Mat& alpha, Mat& outImage) | |
| { | |
| // Find number of pixels. | |
| int numberOfPixels = foreground.rows * foreground.cols * foreground.channels(); | |
| // Get floating point pointers to the data matrices | |
| float* fptr = reinterpret_cast<float*>(foreground.data); | |
| float* bptr = reinterpret_cast<float*>(background.data); | |
| float* aptr = reinterpret_cast<float*>(alpha.data); | |
| float* outImagePtr = reinterpret_cast<float*>(outImage.data); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import cv2 | |
| import argparse | |
| import numpy as np | |
| import os | |
| import logging | |
| #GLOBAL | |
| logging.basicConfig() #Fire up the logger | |
| logger = logging.getLogger() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import cv2 | |
| from matplotlib import pyplot as plt | |
| . . . | |
| #DO PYTHON MATPLOTLIB IMAGE DISPLAY | |
| plt.imshow(image_seg) | |
| plt.draw() | |
| plt.show() # , plt.draw(), plt.show() | |
| plt.pause(0.01) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def text_to_floatlist(pathfile): | |
| f = open(pathfile, 'r') | |
| line = f.readline().strip('[]') | |
| f.close() | |
| return [float(x) for x in line.split()] | |
| #Use | |
| rect = text_to_floatlist(seg_bb[frame_count]) | |
| if(len(rect) < 4): | |
| logger.critical("Length of rectangle not long enough %d",int(len(rect)) ) |
OlderNewer