Computer and Machine Vision

Similar documents
OpenCV. OpenCV Tutorials OpenCV User Guide OpenCV API Reference. docs.opencv.org. F. Xabier Albizuri

Multimedia Retrieval Exercise Course 2 Basic Knowledge about Images in OpenCV

OpenCV. Basics. Department of Electrical Engineering and Computer Science

Computer and Machine Vision

Image Steganalysis Image Steganography

Multimedia Retrieval Exercise Course 2 Basic of Image Processing by OpenCV

Computer and Machine Vision

CS 376b Computer Vision

Computer and Machine Vision

19.1. Unit 19. OpenMP Library for Parallelism

PROGRAMMING IN C++ CVIČENÍ

EE795: Computer Vision and Intelligent Systems

OpenCV Introduction. CS 231a Spring April 15th, 2016

Announcements. CSCI 334: Principles of Programming Languages. Lecture 18: C/C++ Announcements. Announcements. Instructor: Dan Barowy

OpenCV 비디오처리 김성영교수 금오공과대학교 컴퓨터공학과

Computer and Machine Vision

Computer Vision Course Lecture 04. Template Matching Image Pyramids. Ceyhun Burak Akgül, PhD cba-research.com. Spring 2015 Last updated 11/03/2015

Modern C++ for Computer Vision and Image Processing. Igor Bogoslavskyi

Computer and Machine Vision

CSE 12 Spring 2016 Week One, Lecture Two

CS A490 Machine Vision and Computer Graphics

Introduction to OpenCV. Marvin Smith

1. Introduction to the OpenCV library

EMBEDDED SYSTEMS PROGRAMMING Language Basics

CS A485 Computer and Machine Vision

2: Introducing image synthesis. Some orientation how did we get here? Graphics system architecture Overview of OpenGL / GLU / GLUT

Programmazione. Prof. Marco Bertini

Praktikum: 4. Content of today s lecture. Content of today s lecture. Manfred Grove Houxiang Zhang. Program introduction. Program introduction

Scientific Computing

Manfred Grove Houxiang Zhang

Computer and Machine Vision

Templates, Image Pyramids, and Filter Banks

IMPLEMENTATION OF COMPUTER VISION TECHNIQUES USING OPENCV

Image Processing (1) Basic Concepts and Introduction of OpenCV

CS 315 Data Structures Fall Figure 1

Lab#5 Due Wednesday, February 25, at the start of class. Purpose: To develop familiarity with C++ pointer variables

CS 3305 Intro to Threads. Lecture 6

CSE 12 Spring 2018 Week One, Lecture Two

Basic Graphics Programming

stanford hci group / cs377s Lecture 8: OpenCV Dan Maynes-Aminzade Designing Applications that See

Lecture Notes CPSC 224 (Spring 2012) Today... Java basics. S. Bowers 1 of 8

RT Digital Media Extended Lab Choose One: Work Alone Work in a Pair Extra Work Required 3 or More Students May Collaborate, but Submissions must be Un

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

Threaded Programming. Lecture 9: Alternatives to OpenMP

Introduction to Computer Vision

Assumptions. History

CSE 100: STREAM I/O, BITWISE OPERATIONS, BIT STREAM I/O

Pervasive Computing offers Adaptable Interfaces

Representation of image data

Java Basic Syntax. Java vs C++ Wojciech Frohmberg / OOP Laboratory. Poznan University of Technology

More on Func*ons Command Line Arguments CS 16: Solving Problems with Computers I Lecture #8

CE221 Programming in C++ Part 1 Introduction

MPI 1. CSCI 4850/5850 High-Performance Computing Spring 2018

OpenGL/GLUT Intro. Week 1, Fri Jan 12

Overloading Functions & Command Line Use in C++ CS 16: Solving Problems with Computers I Lecture #6

Lab 1: First Steps in C++ - Eclipse

Shared Memory Architectures

Overview of OpenMP. Unit 19. Using OpenMP. Parallel for. OpenMP Library for Parallelism

1/12/11. Basic Graphics Programming. What is OpenGL. OpenGL is cross-platform. How does OpenGL work. How does OpenGL work (continued) The result

Call-by-Type Functions in C++ Command-Line Arguments in C++ CS 16: Solving Problems with Computers I Lecture #5

CS61C Machine Structures. Lecture 3 Introduction to the C Programming Language. 1/23/2006 John Wawrzynek. www-inst.eecs.berkeley.

Programming for Image Analysis/Processing

CS103 Lecture 1 Slides. Introduction Mark Redekopp

Computer and Machine Vision

Lecture 5 Files and Streams

C++ For Science and Engineering Lecture 12

Project 1: Convex hulls and line segment intersection

HW3a solution. L1 implies there must be an f1 in Base L2 implies there must be an f2 in Base. So we know there is an f1 and f2 in Base

Looping and Counting. Lecture 3 Hartmut Kaiser hkaiser/fall_2012/csc1254.html

ECE 661 HW_4. Bharath Kumar Comandur J R 10/02/2012. In this exercise we develop a Harris Corner Detector to extract interest points (such as

Image Processing (1) Basic Concepts and Introduction of OpenCV

Red Hat Developer Tools

CP SC 4040/6040 Computer Graphics Images. Joshua Levine

OpenGL refresher. Advanced Computer Graphics 2012

C++ Code Structure. Cooperating with the Compiler

Real-Time Shadows. Last Time? Today. Why are Shadows Important? Shadows as a Depth Cue. For Intuition about Scene Lighting

LAB #8. GDB can do four main kinds of things (plus other things in support of these) to help you catch bugs in the act:

Maya tutorial. 1 Camera calibration

CS61C : Machine Structures

Abstract Data Types. Lecture 05 Summary. Abstract Data Types Structures in C 1/26/2009. Slides by Mark Hancock (adapted from notes by Craig Schock)

CS2141 Software Development using C/C++ C++ Basics

The Data may not be disclosed or distributed to third parties, in whole or in part, without the prior written consent of Motion Workshop.

Testing, code coverage and static analysis. COSC345 Software Engineering

Real-Time Shadows. Last Time? Textures can Alias. Schedule. Questions? Quiz 1: Tuesday October 26 th, in class (1 week from today!

LAB #8. Last Survey, I promise!!! Please fill out this really quick survey about paired programming and information about your declared major and CS.

DNA Sequence Reads Compression

Computer Vision with MATLAB MATLAB Expo 2012 Steve Kuznicki

CSCE574 Robotics Spring 2014 Notes on Images in ROS

Computational Physics Operating systems

Two s Complement Review. Two s Complement Review. Agenda. Agenda 6/21/2011

Last Time. Reading for Today: Graphics Pipeline. Clipping. Rasterization

Computer Graphics (Basic OpenGL)

Basic program The following is a basic program in C++; Basic C++ Source Code Compiler Object Code Linker (with libraries) Executable

CS427 Multicore Architecture and Parallel Computing

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

Biostatistics 615/815 Lecture 22: Matrix with C++

ME132 February 3, 2011

Computer and Machine Vision

CS61C : Machine Structures

An introduction to Halide. Jonathan Ragan-Kelley (Stanford) Andrew Adams (Google) Dillon Sharlet (Google)

Transcription:

Computer and Machine Vision Lecture Week 12 Part-1 Additional Programming Considerations March 29, 2014 Sam Siewert

Outline of Week 12 Computer Vision APIs and Languages Alternatives to C++ and OpenCV API for Top- Down Halide MATLAB with CV Toolbox Mathematica Additional 3D Scene Considerations Camera Depth of Field Scene Complexities Receiver Operator Curves for Recognition Performance 3D Scene Capture to Point-Cloud-Models Structure from Motion Methods Sam Siewert 2

Major Concepts Post Production Digital Video Frame Processing Pipeline Movie! 1. Acquire, Decode, or Read Frame Files 2. Apply Transforms Simple (Brightness), Convolution (Edge Enhancement), Color Edit, 3. Add CGI Generate Computer Generated Imagery with Rendering 4. Composite Frame with Alpha Blending or Green Screen Human Characters into CGI Background 5. Encode Frames into MPEG Linux Tools Used Today ffmpeg a.k.a avconv, OpenCV, Pixie (Renderman), Python Scripting to Coordinate file-to-tool-to-file RenderMan Pixie MPEG ffmpeg Raw Frames OpenCV Composite Frames ffmpeg Sam Siewert 3

Major Concepts Video Analytics Computer Vision Pipeline Find Bad Guy! 1. Acquire, Decode, or Read Frame Files 2. Apply Transforms Simple (Brightness), Convolution (Edge Enhancement), False Color, Segment, 3-D Correspondence, SIFT, AdaBoost 3. Match to Recognition Database (Facial) 4. Present to User Linux Tools Used Today ffmpeg a.k.a avconv, OpenCV, Python Scripting to Coordinate file-to-tool-to-file MPEG MPEG ffmpeg ffmpeg Raw Frames OpenCV Multicore Sam Siewert 4

Observations APIs Support Building Tools Many Tools Lead to File to File Processing Pipelines File to File is Much Slower than Buffer to Buffer However, File to File Scales with Clusters! Buffer to Buffer Scales with Clusters With MPI or Shared Memory Multi-Core Could Scripting Coordination of File to File Be Replaced with a Language? Could the Language Optimize Use of Buffers (Locality) and Parallel and Vector Processing Hardware Features? Frees Programmer to Explore Options Halide Potential Option Sam Siewert 5

Brighten, Contrast Transform Compare P = clamp[ Q*alpha + beta] Very Simple Scale Each Pixel Brightness Increase/Decrease Bias Each Pixel Contrast Increase/Decrease Make Sure Result Does Not Exceed Saturation Compare C++ OpenCV API and Halide C++ Extension Sam Siewert 6

C Code PPM Brightness/Contrast #define PIXIDX ((i*col*chan)+(j*chan)+k) #define SAT (255) void main(int argc, char *argv[]) char header[512]; unsigned char img[640*480*3], newimg[640*480*3]; int bufflen, hdrlen; unsigned row=0, col=0, chan=0, pix; int i, j, k; double alpha=1.25; unsigned char beta=25; header[0]='\0'; readppm(img, &bufflen, header, &hdrlen, &row, &col, &chan, argv[1]); for(i=0; i < row; i++) for(j=0; j < col; j++) for(k=0; k < chan; k++) newimg[pixidx] = (pix=(unsigned)((img[pixidx])*alpha)+beta) > SAT? SAT : pix; writeppm(newimg, bufflen, header, hdrlen, "brighter.ppm"); Sam Siewert 7

OpenCV C++ API Brighten/Contrast #include <iostream> #include <opencv2/highgui/highgui.hpp> #include <opencv2/core/core.hpp> using namespace cv; using namespace std; double alpha=1.0; int beta=10; /* contrast and brightness control */ int main( int argc, char** argv ) Mat image = imread( argv[1] ); // read in image file Mat new_image = Mat::zeros( image.size(), image.type() ); std::cout<<"* Enter alpha brighten factor [1.0-3.0]: ";std::cin>>alpha; std::cout<<"* Enter beta contrast increase value [0-100]: "; std::cin>>beta; // Do the operation new_image(i,j) = alpha*image(i,j) + beta for( int y = 0; y < image.rows; y++ ) for( int x = 0; x < image.cols; x++ ) for( int c = 0; c < 3; c++ ) new_image.at<vec3b>(y,x)[c] = saturate_cast<uchar>( alpha*( image.at<vec3b>(y,x)[c] ) + beta ); Loop through Rows, Columns, and Color Channels to Apply Dereference Pixel at X,Y for each Color namedwindow("original Image", 1); namedwindow("new Image", 1); imshow("original Image", image); imshow("new Image", new_image); waitkey(); return 0; Sam Siewert 8

Halide Brighten/Contrast // Adapted from Halide tutorial lesson 2. #include <Halide.h> using Halide::Image; #include "../apps/support/image_io.h" int main(int argc, char **argv) Halide::Image<uint8_t> input = load<uint8_t>(argv[1]); Halide::Func brighter; Halide::Var x, y, c; Halide::Expr value = input(x, y, c); value = Halide::cast<float>(value); value = value * 1.5f; value = Halide::min(value, 255.0f); value = Halide::cast<uint8_t>(value); brighter(x, y, c) = value; Halide::Image<uint8_t> output = brighter.realize(input.width(), input.height(), input.channels()); save(output, "brighter.png"); No loop specification, just transform function, so Halide can optimize locality, vector processing and multi-core features. return 0; Sam Siewert 9

Halide Overview http://halide-lang.org/ Decouples Pipeline Specification (Buffer-to-Buffer) and Optimization Built on LLVM and Clang Extensions to C/C++ and Embedding Extension to C++ with Use of Operator Overloading Watch Video Overview on Web Alternatives 1. APIs OpenCV, OpenNI (for C++, Python, Java) 2. Interactive VHLLs MATLAB CV Toolbox, Mathematica 3. IDL Interactive Data Language Discuss API vs. Specialize Language? Sam Siewert 10