From 4024865ea18d170508cfceaf5c60e8162b4ba1fa Mon Sep 17 00:00:00 2001 From: Victor Silva Date: Mon, 13 Aug 2012 16:15:49 -0300 Subject: [PATCH] Add TV transformation (from example) --- .../gen/com/simplecv/hellocamera/R.java | 4 +-- simplecv-android-app/res/values/strings.xml | 2 +- .../HelloCameraNewApiActivity.java | 6 ++-- web-server/tornado_server.py | 31 +++++++++---------- 4 files changed, 21 insertions(+), 22 deletions(-) diff --git a/simplecv-android-app/gen/com/simplecv/hellocamera/R.java b/simplecv-android-app/gen/com/simplecv/hellocamera/R.java index 37b58ce..c988dc3 100644 --- a/simplecv-android-app/gen/com/simplecv/hellocamera/R.java +++ b/simplecv-android-app/gen/com/simplecv/hellocamera/R.java @@ -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; diff --git a/simplecv-android-app/res/values/strings.xml b/simplecv-android-app/res/values/strings.xml index 6e39e7e..8d319db 100644 --- a/simplecv-android-app/res/values/strings.xml +++ b/simplecv-android-app/res/values/strings.xml @@ -14,7 +14,7 @@ Invert Grab Edges 8-bit - Dilate + Tv \ No newline at end of file diff --git a/simplecv-android-app/src/com/simplecv/hellocamera/HelloCameraNewApiActivity.java b/simplecv-android-app/src/com/simplecv/hellocamera/HelloCameraNewApiActivity.java index 130f447..d85bcf9 100644 --- a/simplecv-android-app/src/com/simplecv/hellocamera/HelloCameraNewApiActivity.java +++ b/simplecv-android-app/src/com/simplecv/hellocamera/HelloCameraNewApiActivity.java @@ -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. */ @@ -344,8 +344,8 @@ public void onItemSelected(AdapterView parent, case EIGHT_BIT: transformation = "8bit"; break; - case DILATE: - transformation = "dilate"; + case TV: + transformation = "tv"; break; } } diff --git a/web-server/tornado_server.py b/web-server/tornado_server.py index 08ae3bc..8b9cb0c 100644 --- a/web-server/tornado_server.py +++ b/web-server/tornado_server.py @@ -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): @@ -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)