You are viewing a plain text version of this content. The canonical link for it is here.
Posted to photark-commits@incubator.apache.org by su...@apache.org on 2011/06/22 18:59:08 UTC
svn commit: r1138583 - in /incubator/photark/trunk:
photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/
photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/facebook/
photark-face-recogn...
Author: subash
Date: Wed Jun 22 18:59:07 2011
New Revision: 1138583
URL: http://svn.apache.org/viewvc?rev=1138583&view=rev
Log:
Added FaceBookfriendFinder impl and add it to the composite with a gallery UI button to call the service
Added:
incubator/photark/trunk/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/
incubator/photark/trunk/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/facebook/
incubator/photark/trunk/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/facebook/FacebookFriendFinder.java
incubator/photark/trunk/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/facebook/FacebookFriendFinderImpl.java
Modified:
incubator/photark/trunk/photark-face-recognition/src/main/resources/META-INF/sca-contribution.xml
incubator/photark/trunk/photark-ui/src/main/webapp/gallery.html
incubator/photark/trunk/photark-ui/src/main/webapp/js/constants.js
incubator/photark/trunk/photark-ui/src/main/webapp/js/gallery.js
incubator/photark/trunk/photark-webapp/src/main/webapp/WEB-INF/web.composite
Added: incubator/photark/trunk/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/facebook/FacebookFriendFinder.java
URL: http://svn.apache.org/viewvc/incubator/photark/trunk/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/facebook/FacebookFriendFinder.java?rev=1138583&view=auto
==============================================================================
--- incubator/photark/trunk/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/facebook/FacebookFriendFinder.java (added)
+++ incubator/photark/trunk/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/facebook/FacebookFriendFinder.java Wed Jun 22 18:59:07 2011
@@ -0,0 +1,19 @@
+package org.apache.photark.face.services.applications.facebook;
+
+import org.oasisopen.sca.annotation.Remotable;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: subash
+ * Date: Jun 14, 2011
+ * Time: 11:53:30 PM
+ * To change this template use File | Settings | File Templates.
+ */
+@Remotable
+public interface FacebookFriendFinder {
+
+ public String[] getAllMyFBFriendsInThisPicture(String pathToFile);
+
+ public void setFacebookAuth(String facebookId, String fbAccessToken);
+
+}
Added: incubator/photark/trunk/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/facebook/FacebookFriendFinderImpl.java
URL: http://svn.apache.org/viewvc/incubator/photark/trunk/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/facebook/FacebookFriendFinderImpl.java?rev=1138583&view=auto
==============================================================================
--- incubator/photark/trunk/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/facebook/FacebookFriendFinderImpl.java (added)
+++ incubator/photark/trunk/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/facebook/FacebookFriendFinderImpl.java Wed Jun 22 18:59:07 2011
@@ -0,0 +1,54 @@
+package org.apache.photark.face.services.applications.facebook;
+
+import com.github.mhendred.face4j.exception.FaceClientException;
+import com.github.mhendred.face4j.exception.FaceServerException;
+import com.github.mhendred.face4j.model.Face;
+import com.github.mhendred.face4j.model.Photo;
+import org.apache.photark.face.services.FaceRecognitionService;
+import org.oasisopen.sca.annotation.Reference;
+import org.oasisopen.sca.annotation.Scope;
+
+import java.io.File;
+
+@Scope("COMPOSITE")
+public class FacebookFriendFinderImpl implements FacebookFriendFinder {
+
+ private FaceRecognitionService faceRecognitionService;
+
+ @Reference(name = "faceRecognitionService")
+ protected void setFaceRecognitionService(FaceRecognitionService faceRecognitionService) {
+ this.faceRecognitionService = faceRecognitionService;
+ }
+
+
+ public String[] getAllMyFBFriendsInThisPicture(String pathToFile) {
+ return new String[0];
+ }
+
+ public void setFacebookAuth(String facebookId, String fbAccessToken) {
+ faceRecognitionService.setFacebookOauth2(facebookId,fbAccessToken);
+ }
+
+ private String[] processFBFriends(String filePath) {
+
+ try {
+
+ Photo p = faceRecognitionService.recognizeFromFile(new File(filePath),"friends@facebook.com");
+
+ for(Face face : p.getFaces()) {
+ if(face.getGuess() != null) {
+ System.out.println("***Identified*** "+face.getGuess().toString());
+ } else {
+ System.out.println("??? Unidentified ..");
+ }
+ }
+
+ } catch (FaceClientException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ } catch (FaceServerException e) {
+ e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
+ }
+ return null; //TODO return Facebook IDs of recognized friends
+ }
+
+}
Modified: incubator/photark/trunk/photark-face-recognition/src/main/resources/META-INF/sca-contribution.xml
URL: http://svn.apache.org/viewvc/incubator/photark/trunk/photark-face-recognition/src/main/resources/META-INF/sca-contribution.xml?rev=1138583&r1=1138582&r2=1138583&view=diff
==============================================================================
--- incubator/photark/trunk/photark-face-recognition/src/main/resources/META-INF/sca-contribution.xml (original)
+++ incubator/photark/trunk/photark-face-recognition/src/main/resources/META-INF/sca-contribution.xml Wed Jun 22 18:59:07 2011
@@ -20,8 +20,6 @@
<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
xmlns:photark="http://org.apache.photoark">
<export.java package="org.apache.photark.face.services"/>
- <export.java package="com.github.mhendred.face4j.exception"/>
- <export.java package="com.github.mhendred.face4j.model"/>
- <export.java package="om.github.mhendred.face4j.response"/>
+ <export.java package="org.apache.photark.face.services.applications.facebook"/>
</contribution>
Modified: incubator/photark/trunk/photark-ui/src/main/webapp/gallery.html
URL: http://svn.apache.org/viewvc/incubator/photark/trunk/photark-ui/src/main/webapp/gallery.html?rev=1138583&r1=1138582&r2=1138583&view=diff
==============================================================================
--- incubator/photark/trunk/photark-ui/src/main/webapp/gallery.html (original)
+++ incubator/photark/trunk/photark-ui/src/main/webapp/gallery.html Wed Jun 22 18:59:07 2011
@@ -112,7 +112,7 @@
</td>
<td align="left">
<div id="tags">
- <input id="addtag-input" style="width:20;" type="text" style="display:inline;" value="" size="20" alt="add tag..."/><input type="button" onclick="addTag();" style="display:inline;" value="Add Tag"/>
+ <input id="addtag-input" style="width:20;" type="text" style="display:inline;" value="" size="20" alt="add tag..."/><input type="button" onclick="addTag();" style="display:inline;" value="Add Tag"/><input type="button" onclick="showFacebookFriends();" style="display:inline;" value="facebook"/>
<table id='tableTags' style="margin-left:auto; margin-right:auto;width:150;" border="0"
cellspacing="0" cellpadding="1">
</table>
Modified: incubator/photark/trunk/photark-ui/src/main/webapp/js/constants.js
URL: http://svn.apache.org/viewvc/incubator/photark/trunk/photark-ui/src/main/webapp/js/constants.js?rev=1138583&r1=1138582&r2=1138583&view=diff
==============================================================================
--- incubator/photark/trunk/photark-ui/src/main/webapp/js/constants.js (original)
+++ incubator/photark/trunk/photark-ui/src/main/webapp/js/constants.js Wed Jun 22 18:59:07 2011
@@ -28,6 +28,7 @@ if (! photark.constants) {
photark.constants.contextRoot = "/photark/";
photark.constants.adminContextRoot = "/photark/admin/";
+photark.constants.FacebookFriendFinder = photark.constants.contextRoot + "FacebookFriendFinder?smd";
photark.constants.FaceRecognitionService = photark.constants.contextRoot + "FaceRecognitionService?smd";
photark.constants.RemoteAlbumSubscription = photark.constants.contextRoot + "RemoteAlbumSubscriptionManager?smd";
photark.constants.GalleryServiceEndpoint = photark.constants.contextRoot + "GalleryService?smd";
Modified: incubator/photark/trunk/photark-ui/src/main/webapp/js/gallery.js
URL: http://svn.apache.org/viewvc/incubator/photark/trunk/photark-ui/src/main/webapp/js/gallery.js?rev=1138583&r1=1138582&r2=1138583&view=diff
==============================================================================
--- incubator/photark/trunk/photark-ui/src/main/webapp/js/gallery.js (original)
+++ incubator/photark/trunk/photark-ui/src/main/webapp/js/gallery.js Wed Jun 22 18:59:07 2011
@@ -57,8 +57,9 @@ var SECURITY_TOKEN;
var permissions = new Array();
var albumImageToBeLoaded = null;
-var FACE_API_KEY = "";
-var FACE_API_SECRET = "";
+var FACE_API_KEY = "5ae7a7ddcba07b5d4731930bfe06f4c7";
+var FACE_API_SECRET = "6877f93df2c2bcef2a1ddb6ba26a0d6c";
+var facebook_ff;
dojo.addOnLoad(function() {
dojo.require("dojo._base.xhr");
@@ -96,8 +97,8 @@ function initServices(){
gallery = new dojo.rpc.JsonService( photark.constants.GalleryServiceEndpoint );
remoteGallery = new dojo.rpc.JsonService(photark.constants.RemoteGalleryServiceEndpoint);
faceService = new dojo.rpc.JsonService(photark.constants.FaceRecognitionService);
-// faceService.createNewDefaultFaceClient(FACE_API_KEY,FACE_API_SECRET).addCallback(face_callback);
-
+ faceService.createNewDefaultFaceClient(FACE_API_KEY,FACE_API_SECRET).addCallback(face_callback);
+ facebook_ff = new dojo.rpc.JsonService(photark.constants.FacebookFriendFinder);
}
function initGallery() {
@@ -277,6 +278,10 @@ function addTag() {
}
+function showFacebookFriends(){
+ facebook_ff.getAllMyFBFriendsInThisPicture().addCallback(facebook_ff_callback);
+}
+
function face_callback(items, exception) {
if(exception) {
// alert(exception.msg);
@@ -287,6 +292,17 @@ function face_callback(items, exception)
}
+function facebook_ff_callback(items, exception) {
+ if(exception) {
+ // alert(exception.msg);
+ displayGallery();
+ logout();
+ // return;
+ }
+ alert(items[0]);
+
+}
+
function initializeRemoteGallery() {
var table=document.getElementById('remoteTableGallery');
Modified: incubator/photark/trunk/photark-webapp/src/main/webapp/WEB-INF/web.composite
URL: http://svn.apache.org/viewvc/incubator/photark/trunk/photark-webapp/src/main/webapp/WEB-INF/web.composite?rev=1138583&r1=1138582&r2=1138583&view=diff
==============================================================================
--- incubator/photark/trunk/photark-webapp/src/main/webapp/WEB-INF/web.composite (original)
+++ incubator/photark/trunk/photark-webapp/src/main/webapp/WEB-INF/web.composite Wed Jun 22 18:59:07 2011
@@ -177,6 +177,17 @@
<tuscany:binding.jsonrpc uri="/FaceRecognitionService"/>
</service>
</component>
+
+ <component name="FacebookFriendFinder">
+ <implementation.java class="org.apache.photark.face.services.applications.facebook.FacebookFriendFinderImpl"/>
+
+ <service name="FacebookFriendFinder">
+ <interface.java interface="org.apache.photark.face.services.applications.facebook.FacebookFriendFinder"/>
+ <binding.sca name="local"/>
+ <tuscany:binding.jsonrpc uri="/FacebookFriendFinder"/>
+ </service>
+ <reference name="faceRecognitionService" target="FaceRecognitionService"/>
+ </component>
</composite>