<<python computer vision with opencv>> chapter 2

import cv2
import numpy
import os

# Make an array of 120,000 random bytes.
randomByteArray = bytearray(os.urandom(120000))
flatNumpyArray = numpy.array(randomByteArray)

# Convert the array to make a 400x300 grayscale image.
grayImage = flatNumpyArray.reshape(300, 400)
# Assignment 
grayImage[0, 0] = 0

# grayImage.setitem([0, 1], 128)
# AttributeError: 'numpy.ndarray' object has no attribute 'setitem'

# Write image
cv2.imwrite('RandomGray.png', grayImage)



# Convert the array to make a 400x100 color image.
bgrImage = flatNumpyArray.reshape(100, 400, 3)

# 24-bit BGR image with a Red pixel in the upper-left corner
bgrImage[0, 0] = [0, 0, 255] #  [0, 0, 255] from left to right --> 0: Blue; 0: Green; 0: Red

cv2.imwrite('RandomColor.png', bgrImage)






CameraCaptureFrames write to avi video

import cv2

cameraCapture = cv2.VideoCapture(0)
fps = 1 # an assumption
size = (int(cameraCapture.get(cv2.cv.CV_CAP_PROP_FRAME_WIDTH)),
        int(cameraCapture.get(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT)))
videoWriter = cv2.VideoWriter('MyOutputVid.avi',
                              cv2.cv.CV_FOURCC('I','4','2','0'),
                              fps, size)
success, frame = cameraCapture.read()
numFramesRemaining = 10 * fps - 1
while success and numFramesRemaining > 0:
    videoWriter.write(frame)
    success, frame = cameraCapture.read()
    numFramesRemaining -= 1


Hands-On Computer Vision with Julia: Build complex applications with advanced Julia packages for image processing, neural networks, and Artificial Intelligence Explore the various packages in Julia that support image processing and build neural networks for video processing and object tracking. Key Features Build a full-fledged image processing application using JuliaImages Perform basic to advanced image and video stream processing with Julia's APIs Understand and optimize various features of OpenCV with easy examples Book Description Hands-On Computer Vision with Julia is a thorough guide for developers who want to get started with building computer vision applications using Julia. Julia is well suited to image processing because it's easy to use and lets you write easy-to-compile and efficient machine code. This book begins by introducing you to Julia's image processing libraries such as Images.jl and ImageCore.jl. You'll get to grips with analyzing and transforming images using JuliaImages; some of the techniques discussed include enhancing and adjusting images. As you make your way through the chapters, you'll learn how to classify images, cluster them, and apply neural networks to solve computer vision problems. In the concluding chapters, you will explore OpenCV applications to perform real-time computer vision analysis, for example, face detection and object tracking. You will also understand Julia's interaction with Tesseract to perform optical character recognition and build an application that brings together all the techniques we introduced previously to consolidate the concepts learned. By end of the book, you will have understood how to utilize various Julia packages and a few open source libraries such as Tesseract and OpenCV to solve computer vision problems with ease. What you will learn Analyze image metadata and identify critical data using JuliaImages Apply filters and improve image quality and color schemes Extract 2D features for image com
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Digital2Slave

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值