Skip to content

Commit

Permalink
Add TV transformation (from example)
Browse files Browse the repository at this point in the history
  • Loading branch information
victorssilva committed Aug 13, 2012
1 parent f6df55b commit 4024865
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 22 deletions.
4 changes: 2 additions & 2 deletions simplecv-android-app/gen/com/simplecv/hellocamera/R.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public static final class drawable {
public static final class id {
public static final int capturedimage=0x7f060008;
public static final int choose_picture_button=0x7f060003;
public static final int clockwise_button=0x7f060006;
public static final int counterclockwise_button=0x7f060007;
public static final int clockwise_button=0x7f060007;
public static final int counterclockwise_button=0x7f060006;
public static final int go_button=0x7f060005;
public static final int modifiedimage=0x7f060001;
public static final int share_button=0x7f060000;
Expand Down
2 changes: 1 addition & 1 deletion simplecv-android-app/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<item>Invert</item>
<item>Grab Edges</item>
<item>8-bit</item>
<item>Dilate</item>
<item>Tv</item>
</string-array>

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public class HelloCameraNewApiActivity extends Activity {
private static final int INVERT = 0;
private static final int GRAB_EDGES = 1;
private static final int EIGHT_BIT = 2;
private static final int DILATE = 3;
private static final int TV = 3;


/** Called when the activity is first created. */
Expand Down Expand Up @@ -344,8 +344,8 @@ public void onItemSelected(AdapterView<?> parent,
case EIGHT_BIT:
transformation = "8bit";
break;
case DILATE:
transformation = "dilate";
case TV:
transformation = "tv";
break;
}
}
Expand Down
31 changes: 15 additions & 16 deletions web-server/tornado_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,25 @@
dir_original = "files/uploads/original/"

def get_edges(image_path):
img = Image(image_path)
img = img.edges()
img.save(image_path)
return

def divide(image_path):
img = Image(image_path)
img = img / 10
img = Image(image_path).edges()
img.save(image_path)
return

def invert(image_path):
img = Image(image_path)
img = img.invert()
img = Image(image_path).invert()
img.save(image_path)
return

def dilate(image_path):
img = Image(image_path)
img = img.dilate(5)
img.save(image_path)
def tv(image_path):
tv_original = Image("family_watching_television_1958.jpg", sample=True)
tv_coordinates = [(353, 379), (433,380),(432, 448), (354,446)]
tv_mask = Image(tv_original.size()).invert().warp(tv_coordinates)
tv = tv_original - tv_mask

bwimage = Image(image_path).grayscale().resize(tv.width, tv.height)
on_tv = tv + bwimage.warp(tv_coordinates)

on_tv.save(image_path)
return

def eight_bit(image_path):
Expand All @@ -50,10 +48,11 @@ def eight_bit(image_path):
img.save(image_path)
return

transformations_dict = {'edges': get_edges, 'divide': divide,
'invert': invert, 'dilate': dilate,
transformations_dict = {'edges': get_edges,
'invert': invert, 'tv': tv,
'8bit': eight_bit }


def fix_rotation(image_path, rotation):
img = Image(image_path)
img = img.rotate(-rotation, fixed=False)
Expand Down

0 comments on commit 4024865

Please sign in to comment.