Move Constructor

Andrzej's C++ blog

One of the new features in C++11 – move semantics, or r-value references – are already available in a couple of new compilers and have been well described in a number of articles, e.g., by Danny Kalev, Dave Abrahams, and Howard E. Hinnant, Bjarne Stroustrup & Bronek Kozicki. In this post I try to describe only one aspect or the new feature: the move constructor. If you are not yet familiar with r-value references this will be a soft start. If you already are, you may still find the article useful, as I tried to approach the subject from a different angle.

View original post 1,601 more words

PORT or STARBOARD, PIC I/O registers ahoy.

Single color detection using OpenCV

ZC's blog

This blog has been stopped and transferred to https://linzichun.com in June 2018.  some history posts are hidden!

—————————————————————–

After a few days of learning OpenCV, I started to write my first OpenCV program, the requirement is to detect single color and find three largest color objects, it’s a very basic program, but you can know a lot about computer vision if you understand the code. OpenCV provide so many functions, you have to know what you want and what the function does.

This program still run on the Raspberry Pi, frame per second is about 8.5, if you want to find more or less than 3 biggest objects, you can change N. Here is code(You also can get it in my Github) sg_color.c:

Here is makefile:

LIBS= `pkg-config --libs opencv` CFLAGS= `pkg-config --cflags opencv` objects= sg_color.o sg_color: $(objects) gcc $(LIBS)$(CFLAGS) -o sg_color $(objects) .PHONY: clean…

View original post 11 more words

Visual Intelligence : Human vs Machine

Blog

Ever wondered how visually intelligent our brain is ? or How much has machine vision achieved in mimicking human vision till now ? Lets start by observing a picture

Human Vision (1) Human Vision (1)

Each of these children is observing the world surrounding him/her. They can identify shape and color of various patches in the room. They can also classify objects, the actions of teacher and most importantly ,identify the visually related social behavior of objects in the environment.

By the age of two, our visual cortex becomes so well trained that we can understand any scene without rationalizing its pixel space. This becomes clear from the following example :-

Famous Ponzo Optical Illusion Famous Ponzo’s Optical Illusion

Observe how quickly your brain understands the scene , albeit it falters in guessing that the size of three vehicles are equal. On the other hand, machine vision is still in its infancy. There are algorithms that accurately…

View original post 157 more words

Researchers are using deep learning to predict how we pose. It’s more important than it sounds

Gigaom

A team of New York University researchers that includes Facebook AI Lab Director Yann LeCun recently published a paper explaining how they built a deep learning model capable of predicting the position of human limbs in images. That field of computer vision, called human pose estimation, doesn’t get as much attention as things like facial recognition or object recognition, but it’s actually quite difficult and potentially very important in fields such as human-computer interaction and computer animation.

Computers that can accurately identify the positions of people’s arms, legs, joints and general body alignment could lead to better gesture-based controls for interactive displays, more-accurate markerless (i.e., no sensors stuck to people’s bodies) motion-capture systems, and robots (or other computers) that can infer actions as well as identify objects. Even in situations where it’s difficult or impossible to see or distinguish a part of somebody’s body, or even an entire side, pose-estimation systems should be smart…

View original post 381 more words

Algorithms: heap data structure and intro to Greedy Algorithms

drawing with data

I’m currently taking the Algorithms 1/Algorithms 2 courses on Coursera.  This is an aside from pure data viz, but is good to get this part of the core cs foundation.  And, it’s fun!

Today’s lectures & main take-away messages

Heaps as Data Structures: (1) if you find yourself doing repeated minimum (or maximum) computations, consider a heap and (2) choosing the right data structure can decrease an algorithm’s running time

Intro to Greedy Algorithms: (1) Greedy algorithms are one of the major algorithm design paradigms along with divide & conquer, randomized, and dynamic programming.  (2) Comparing Greedy to Divide & Conquer, greedy algorithms are generally easier to apply while you need the right insight to find how to decompose for D & C, easier to calculate Big O classification since often one aspect of the algorithm dominates, but typically non-trivial to prove correctness.

Optimal Caching as an…

View original post 117 more words

Always write a generalized version of your algorithm

Airspeed Velocity

Suppose you want to find the minimum value in an array. Well, the Swift standard library has you covered:

Ok that’s cool. But suppose you have an array of strings of integers and you want the minimum numeric value.

Well, I guess you could map them to Int and then use the same function:

Nope, compiler error. String.toInt returns an Int?, because maybe the string isn’t a number.

Fair enough. I happen to know with my intimate knowledge of the problem domain that we can just ignore non-numeric values. So maybe filter those out?

Nope, more compiler errors, because now we have only non-nil values, but they’re still optionals and an Int? doesn’t conform to Comparable. So maybe another map to force-unwrap the results (force unwrap is OK because the filter will guarantee no non-nil elements):1

Ok that compiles now and does return the minimum numeric…

View original post 457 more words

Linked List with read-write locks for the entire linked list in C

Chameerawijebandara's Blog

Introduction

his implementation support Member( )Insert( ), and Delete( ) functions. Populate the linked list with n random, but unique values. Each value should be between 0 and 2^16– 1. Then perform m random Member, Insert, and Delete operations on the link list. Let mMember, mInsert, and mDelete be the fractions of operations of each type. You may use any values within 0 and 2^16– 1 while performing these three operations.

However, to simplify the implementation, a new value inserted into the list cannot be a value already in the list (it may be a value that was initially added to the list, but later removed).

Code

View original post

Complete binary search tree in Java

Rotation in Binary trees

Chameerawijebandara's Blog

As a example I have use RIGHT-ROTATE to present the steps of the rotations. LEFT-ROTATE is also semantic.

RIGHT-ROTATE(T, x)

  1.         y = x.left                              // set y
  2.         x.left = y.right                    // turn y’s right sub tree into x’s left sub tree
  3.         if y.right ≠ NULL
  4.                         y.right.parent = x
  5.         y.parent = x.parent         // link x’s parent to y
  6.         if x.parent == NULL
  7.                         T.root = y
  8.         else if x == x.parent.left
  9.                         x.parent.left = y
  10.         else
  11.                         x.parent.right = y
  12.         y.right = x                            // put x on y’s right
  13.         x.parent = y

Assumptions

  • Assume that the n items are distinct.

step_0step_1step_2step_3step_4step_5step_6step_7

View original post