PORT or STARBOARD, PIC I/O registers ahoy.

Originally posted on electronics and programming beginners guide:

Keep in mind while reading this that this is a general guide and there are always exceptions. The following is a snap shot of a data sheet from the PIC16F1829. This is the processor that comes with the pickit3 starter kit.

pic16f1829

The pictured register is for an 8bit pic hence the register is 8bits wide. PICs that are 16bit and 32bit have registers that are 16bits wide and 32bits wide respectively. Registers are how the software controls the hardware, also called special function registers (SFR). This resister is called TRIS and it controls weather a pin is a input or output.pic16f1829 1

Above is the name of the register  boxed in red. The name of the register can be worked with just like a variable. For example this sets the zero bit of the TRISA register. To “set” a bit means to store a 1 in it. To “clear” a bit…

View original 451 more words

Single color detection using OpenCV

Originally posted on Live and Laugh:

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 sg_color.c:
1
#include <stdio.h>
#include <time.h>

#include "cv.h"
#include "highgui.h"

#define N 3 //the max num of blobs found

IplImage* Threshold(IplImage* imgThresh,IplImage* imgHSV)
{
cvInRangeS(imgHSV, cvScalar(160,175,75,0), cvScalar(180,255,255,0), imgThresh);
cvDilate(imgThresh,imgThresh,NULL,1);
cvErode(imgThresh,imgThresh,NULL,1);
return imgThresh;
}

int main()
{
time_t start,end;
////// Variables /////////////////////////////////////////////////////
CvMemStorage *storage = cvCreateMemStorage(0);
CvSeq *contours[N], *tmp_cont, *contour;
IplImage *frame…

View original 235 more words

Visual Intelligence : Human vs Machine

Originally posted on 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 157 more words

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

Originally posted on 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 394 more words

Algorithms: heap data structure and intro to Greedy Algorithms

Originally posted on 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 117 more words

Always write a generalized version of your algorithm

Originally posted on Airspeed Velocity:

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

1

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:

1

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?

1

Nope, more compiler errors, because now we have only non-nil values…

View original 621 more words

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

Originally posted on 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

1

/* File: serial_linked_list .c
* Purpose: Implement a linked list as a Parallel program (based on Pthreads) with read-write locks for the entire linked list
* Implementation should support Member( ), Insert( ), and Delete( ) functions.
* Populate the linked list with n…

View original 1,160 more words

Complete binary search tree in Java

Originally posted on Chameerawijebandara's Blog:

1

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package trees;

/**
*
* @author wijebandara
*/
public class BinarySearchTrees {

private NodeBST head;

/**
*
* @param n
*/
public void insert(int n) {
if (head != null) {
NodeBST hold = head;
while (true) {
if (hold.data > n) {
if (hold.left == null) {
hold.left = new NodeBST(n, hold);
break;
} else {
hold = hold.left;
}
} else {
if (hold.right == null) {
hold.right = new NodeBST(n, hold);
break;
} else {
hold = hold.right;
}
}
}
} else {
head = new NodeBST(n);
}

}

/**
*
*/
public void showPostOrder() {
if (head != null) {
showPostOrder(head);
System.out.println();
} else {
System.out.println("NULL");
}
}

private void showPostOrder(NodeBST hold) {
if (hold.right != null) {
showPostOrder(hold.right);
}

if (hold.left != null) {
showPostOrder(hold.left);

View original 672 more words

Rotation in Binary trees

Originally posted on 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

Words for young game developers and Northern Game Summit

Originally posted on digitalerr0r:

Last week I attended the Northern Game Summit, an awesome event hosted in Kajaani Finland. The event gathered somewhere around 700 attendees who all got one thing in common – creating awesome games.

I was lucky enough to be invited there to keep three presentations around Unity and game development. My talks was around getting started with developing games, getting your games published to Windows Store and Windows Phone Store, and how to get connected using the cloud.

Most of my content was based on my Unity for Windows tutorial series – but the coolest thing was the networking and meeting some of the guys behind Angry Birds, Badland, EVE Online, Alan Wake and a lot of motivated startups and students with one thing on their mind – trying to create good games, and experience worth hours of gameplay for us consumers.

Somehow, Finland manages to create games that…

View original 377 more words

Follow

Get every new post delivered to your Inbox.

Join 228 other followers