Added bean classes to PhotArk Face Services to refactore the FaceRecognitionService interface
git-svn-id: https://svn.apache.org/repos/asf/incubator/photark/trunk@1153642 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/photark-face-recognition/src/main/java/org/apache/photark/face/services/FaceRecognitionService.java b/photark-face-recognition/src/main/java/org/apache/photark/face/services/FaceRecognitionService.java
index 81f1ea9..a41264c 100644
--- a/photark-face-recognition/src/main/java/org/apache/photark/face/services/FaceRecognitionService.java
+++ b/photark-face-recognition/src/main/java/org/apache/photark/face/services/FaceRecognitionService.java
@@ -25,6 +25,7 @@
import com.github.mhendred.face4j.response.LimitsResponse;
import com.github.mhendred.face4j.response.TrainResponse;
import com.github.mhendred.face4j.response.UsersResponse;
+import org.apache.photark.face.services.beans.PhotarkPhoto;
import org.oasisopen.sca.annotation.Remotable;
import java.io.File;
@@ -124,7 +125,7 @@
* @throws FaceClientException
* @throws FaceServerException
*/
- public Photo recognizeFromFile(File imageFile, String uids) throws FaceClientException, FaceServerException;
+ public PhotarkPhoto recognizeFromFile(File imageFile, String uids) throws FaceClientException, FaceServerException;
/**
* Recognizes same as {@recognizeFromFile} except, this time the domain can be given as a url itself.
@@ -134,7 +135,7 @@
* @throws FaceClientException
* @throws FaceServerException
*/
- public List<Photo> recognizeFromUrls(String urls, String uids) throws FaceClientException, FaceServerException ;
+ public List<PhotarkPhoto> recognizeFromUrls(String urls, String uids) throws FaceClientException, FaceServerException ;
/** Gives tags of the detected faces of the given photo with multiple details of the Photo
*
diff --git a/photark-face-recognition/src/main/java/org/apache/photark/face/services/FaceRecognitionServiceImpl.java b/photark-face-recognition/src/main/java/org/apache/photark/face/services/FaceRecognitionServiceImpl.java
index ab28874..9b60e5a 100644
--- a/photark-face-recognition/src/main/java/org/apache/photark/face/services/FaceRecognitionServiceImpl.java
+++ b/photark-face-recognition/src/main/java/org/apache/photark/face/services/FaceRecognitionServiceImpl.java
@@ -21,17 +21,17 @@
import java.io.File;
import java.util.List;
+import com.github.mhendred.face4j.model.*;
+import org.apache.photark.face.services.beans.BeanGeneratorUtil;
+import org.apache.photark.face.services.beans.PhotArkFace;
+import org.apache.photark.face.services.beans.PhotarkPhoto;
+import org.oasisopen.sca.annotation.Init;
import org.oasisopen.sca.annotation.Scope;
import org.oasisopen.sca.annotation.Service;
import com.github.mhendred.face4j.DefaultFaceClient;
import com.github.mhendred.face4j.exception.FaceClientException;
import com.github.mhendred.face4j.exception.FaceServerException;
-import com.github.mhendred.face4j.model.Namespace;
-import com.github.mhendred.face4j.model.Photo;
-import com.github.mhendred.face4j.model.RemovedTag;
-import com.github.mhendred.face4j.model.SavedTag;
-import com.github.mhendred.face4j.model.UserStatus;
import com.github.mhendred.face4j.response.GroupResponse;
import com.github.mhendred.face4j.response.LimitsResponse;
import com.github.mhendred.face4j.response.TrainResponse;
@@ -42,6 +42,14 @@
public class FaceRecognitionServiceImpl implements FaceRecognitionService {
private DefaultFaceClient defaultFaceClient;
+ private String API_KEY = "";
+ private String API_SECRET = "";
+
+
+ @Init
+ public void init() {
+ defaultFaceClient = new DefaultFaceClient(API_KEY,API_SECRET);
+ }
/**
* @see {@link FaceRecognitionService#removeTags(String)}
@@ -88,15 +96,20 @@
/**
* @see {@link FaceRecognitionService#recognizeFromFile(File,String)}
*/
- public Photo recognizeFromFile(File imageFile, String uids) throws FaceClientException, FaceServerException {
- return defaultFaceClient.recognize(imageFile, uids);
+ public PhotarkPhoto recognizeFromFile(File imageFile, String uids) throws FaceClientException, FaceServerException {
+ Photo photo = defaultFaceClient.recognize(imageFile, uids);
+ return BeanGeneratorUtil.createPhotarkPhoto(photo);
}
/**
* @see {@link FaceRecognitionService#recognizeFromUrls(String,String)}
*/
- public List<Photo> recognizeFromUrls(String urls, String uids) throws FaceClientException, FaceServerException {
- return defaultFaceClient.recognize(urls, uids);
+ public List<PhotarkPhoto> recognizeFromUrls(String urls, String uids) throws FaceClientException, FaceServerException {
+ List<PhotarkPhoto> photarkPhotoList = null;
+ for(Photo p : defaultFaceClient.recognize(urls, uids)) {
+ photarkPhotoList.add(BeanGeneratorUtil.createPhotarkPhoto(p));
+ }
+ return photarkPhotoList ;
}
/**
@@ -218,4 +231,5 @@
defaultFaceClient = new DefaultFaceClient(apiKey, apiSecret);
}
+
}
diff --git a/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/facebook/FacebookFriendFinder.java b/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/facebook/FacebookFriendFinder.java
index 6c475b4..41dbc17 100644
--- a/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/facebook/FacebookFriendFinder.java
+++ b/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/facebook/FacebookFriendFinder.java
@@ -24,7 +24,9 @@
@Remotable
public interface FacebookFriendFinder {
- public Entry<String, String>[] getAllMyFBFriendsInThisPicture(String pathToFile);
+ public Entry<String, String>[] getAllMyFBFriendsFromPictureLocal(String pathToFile);
+
+ public Entry<String, String>[] getAllMyFBFriendsFromPictureUrl(String fileUrl);
public void setFacebookAuth(String facebookId, String fbAccessToken);
diff --git a/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/facebook/FacebookFriendFinderImpl.java b/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/facebook/FacebookFriendFinderImpl.java
index 049a43c..7803109 100644
--- a/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/facebook/FacebookFriendFinderImpl.java
+++ b/photark-face-recognition/src/main/java/org/apache/photark/face/services/applications/facebook/FacebookFriendFinderImpl.java
@@ -20,9 +20,9 @@
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.apache.photark.face.services.beans.PhotArkFace;
+import org.apache.photark.face.services.beans.PhotarkPhoto;
import org.apache.tuscany.sca.data.collection.Entry;
import org.oasisopen.sca.annotation.Reference;
import org.oasisopen.sca.annotation.Scope;
@@ -35,33 +35,50 @@
public class FacebookFriendFinderImpl implements FacebookFriendFinder {
private FaceRecognitionService faceRecognitionService;
+ private final String adamFBUserId = "";
+ private final String adamAccessToken = "";
+
@Reference(name = "faceRecognitionService")
protected void setFaceRecognitionService(FaceRecognitionService faceRecognitionService) {
this.faceRecognitionService = faceRecognitionService;
}
- public Entry<String, String>[] getAllMyFBFriendsInThisPicture(String pathToFile) {
- return processFBFriends(pathToFile);
+ public Entry<String, String>[] getAllMyFBFriendsFromPictureLocal(String pathToFile) {
+
+ return processFBFriends(pathToFile, true);
+ }
+
+ public Entry<String, String>[] getAllMyFBFriendsFromPictureUrl(String fileUrl) {
+
+ return processFBFriends(fileUrl, false);
}
public void setFacebookAuth(String facebookId, String fbAccessToken) {
faceRecognitionService.setFacebookOauth2(facebookId, fbAccessToken);
}
- private Entry<String, String>[] processFBFriends(String filePath) {
+ private Entry<String, String>[] processFBFriends(String fileLocation, boolean isLocal) {
+
+ PhotarkPhoto photo = null;
List<Entry<String, String>> detectedFriends = new ArrayList<Entry<String, String>>();
+
try {
+ faceRecognitionService.setFacebookOauth2(adamFBUserId, adamAccessToken);
+ if (isLocal) {
+ photo = faceRecognitionService.recognizeFromFile(new File(fileLocation), "friends@facebook.com");
+ } else {
+ photo = faceRecognitionService.recognizeFromUrls(fileLocation, "friends@facebook.com").get(0);
+ }
- Photo p = faceRecognitionService.recognizeFromFile(new File(filePath), "friends@facebook.com");
+ for (PhotArkFace face : photo.getPhotArkFaces()) {
- for (Face face : p.getFaces()) {
String uid = "";
String confidence = "";
if (face.getGuess() != null) {
System.out.println("***Identified*** " + face.getGuess().toString());
- uid = getFBUID(face.getGuess().toString());
- confidence = getFaceConfidence(face.getGuess().toString());
+ uid = face.getGuess().getGuessID();
+ confidence = face.getGuess().getConfidence();
detectedFriends.add(new Entry<String, String>(uid, confidence));
} else {
System.out.println("??? Unidentified ..");
@@ -74,16 +91,8 @@
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
Entry<String, String>[] imageArray = new Entry[detectedFriends.size()];
-
return detectedFriends.toArray(imageArray);
- }
- private String getFBUID(String s) {
- return s.substring(1, s.length() - 1).split(",")[1].trim().split("=")[1].split("@")[0];
- }
-
- private String getFaceConfidence(String s) {
- return s.substring(1, s.length() - 1).split(",")[0].trim().split("=")[1];
}
}
diff --git a/photark-face-recognition/src/main/java/org/apache/photark/face/services/beans/BeanGeneratorUtil.java b/photark-face-recognition/src/main/java/org/apache/photark/face/services/beans/BeanGeneratorUtil.java
new file mode 100644
index 0000000..002ff30
--- /dev/null
+++ b/photark-face-recognition/src/main/java/org/apache/photark/face/services/beans/BeanGeneratorUtil.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.photark.face.services.beans;
+
+import com.github.mhendred.face4j.model.Face;
+import com.github.mhendred.face4j.model.Guess;
+import com.github.mhendred.face4j.model.Photo;
+import java.util.ArrayList;
+import java.util.List;
+
+public class BeanGeneratorUtil {
+
+
+ public static PhotarkPhoto createPhotarkPhoto(Photo photo) {
+
+ PhotarkPhoto photarkPhoto = new PhotarkPhoto(photo.getPID(), photo.getURL(), photo.getFaceCount());
+ photarkPhoto.setPhotArkFace(createPhotArkFace(photo.getFace()));
+ List<PhotArkFace> photArkFaceList = new ArrayList<PhotArkFace>();
+
+ for (Face f : photo.getFaces()) {
+ photArkFaceList.add(createPhotArkFace(f));
+ }
+ photarkPhoto.setPhotArkFaces(photArkFaceList);
+ return photarkPhoto;
+ }
+
+ public static PhotArkFace createPhotArkFace(Face face) {
+
+ PhotArkFace photArkFace = new PhotArkFace(face.getTID(), getGender(face));
+ photArkFace.setGuess(createPhotArkGuess(face.getGuess()));
+ List<PhotArkGuess> photArkGuessList = new ArrayList<PhotArkGuess>();
+
+ for (Guess g : face.getGuesses()) {
+ photArkGuessList.add(createPhotArkGuess(g));
+ }
+ photArkFace.setGuesses(photArkGuessList);
+ return photArkFace;
+ }
+
+ public static PhotArkGuess createPhotArkGuess(Guess guess) {
+ if (guess == null) {
+ return new PhotArkGuess(null, null);
+ } else {
+ return new PhotArkGuess(guess.second.toString(), guess.first.toString());
+ }
+ }
+
+ private static String getGender(Face face) {
+ if (face.getGender() != null) {
+ return face.getGender().name();
+ } else {
+ return null;
+ }
+ }
+
+
+}
diff --git a/photark-face-recognition/src/main/java/org/apache/photark/face/services/beans/PhotArkFace.java b/photark-face-recognition/src/main/java/org/apache/photark/face/services/beans/PhotArkFace.java
new file mode 100644
index 0000000..954f4cb
--- /dev/null
+++ b/photark-face-recognition/src/main/java/org/apache/photark/face/services/beans/PhotArkFace.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.photark.face.services.beans;
+
+import java.io.Serializable;
+import java.util.List;
+
+public class PhotArkFace implements Serializable {
+
+ private String tid;
+ private String gender;
+ private PhotArkGuess guess;
+ private List<PhotArkGuess> guesses;
+
+ public PhotArkFace(String tid, String gender) {
+ this.tid = tid;
+ this.gender = gender;
+ }
+
+ public String getTid() {
+ return tid;
+ }
+
+ public void setTid(String tid) {
+ this.tid = tid;
+ }
+
+ public void setGuesses(List<PhotArkGuess> guesses) {
+ this.guesses = guesses;
+ }
+
+ public void setGuess(PhotArkGuess guess) {
+ this.guess = guess;
+ }
+
+ public void setGender(String gender) {
+ this.gender = gender;
+ }
+
+ public String getGender() {
+ return gender;
+ }
+
+ public PhotArkGuess getGuess() {
+ return guess;
+ }
+
+ public List<PhotArkGuess> getGuesses() {
+ return guesses;
+ }
+
+}
diff --git a/photark-face-recognition/src/main/java/org/apache/photark/face/services/beans/PhotArkGuess.java b/photark-face-recognition/src/main/java/org/apache/photark/face/services/beans/PhotArkGuess.java
new file mode 100644
index 0000000..d3dc664
--- /dev/null
+++ b/photark-face-recognition/src/main/java/org/apache/photark/face/services/beans/PhotArkGuess.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.photark.face.services.beans;
+
+import java.io.Serializable;
+
+public class PhotArkGuess implements Serializable {
+ private String confidence;
+ private String guessID;
+
+ public PhotArkGuess(String confidence, String guessID) {
+ this.confidence = confidence;
+ this.guessID = guessID;
+ }
+
+ public String getConfidence() {
+ return confidence;
+ }
+
+ public void setConfidence(String confidence) {
+ this.confidence = confidence;
+ }
+
+ public void setGuessID(String guessID) {
+ this.guessID = guessID;
+ }
+
+ public String getGuessID() {
+ return guessID;
+ }
+}
diff --git a/photark-face-recognition/src/main/java/org/apache/photark/face/services/beans/PhotarkPhoto.java b/photark-face-recognition/src/main/java/org/apache/photark/face/services/beans/PhotarkPhoto.java
new file mode 100644
index 0000000..f04f70b
--- /dev/null
+++ b/photark-face-recognition/src/main/java/org/apache/photark/face/services/beans/PhotarkPhoto.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.photark.face.services.beans;
+
+import java.io.Serializable;
+import java.util.List;
+
+public class PhotarkPhoto implements Serializable {
+
+ private String pid;
+ private String url;
+ private int faceCount;
+ private PhotArkFace photArkFace;
+ private List<PhotArkFace> photArkFaces;
+
+ public PhotarkPhoto(String pid, String url, int faceCount) {
+ this.pid = pid;
+ this.url = url;
+ this.faceCount = faceCount;
+ }
+
+ public void setPid(String pid) {
+ this.pid = pid;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public void setFaceCount(int faceCount) {
+ this.faceCount = faceCount;
+ }
+
+ public void setPhotArkFace(PhotArkFace photArkFace) {
+ this.photArkFace = photArkFace;
+ }
+
+ public void setPhotArkFaces(List<PhotArkFace> photArkFaces) {
+ this.photArkFaces = photArkFaces;
+ }
+
+ public String getPid() {
+ return pid;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public int getFaceCount() {
+ return faceCount;
+ }
+
+ public PhotArkFace getPhotArkFace() {
+ return photArkFace;
+ }
+
+ public List<PhotArkFace> getPhotArkFaces() {
+ return photArkFaces;
+ }
+
+}
diff --git a/photark-face-recognition/src/test/java/org/apache/photark/face/facebook/test/GenericFaceRecognitionTestCase.java b/photark-face-recognition/src/test/java/org/apache/photark/face/facebook/test/GenericFaceRecognitionTestCase.java
index 2e5dee9..0f7335e 100644
--- a/photark-face-recognition/src/test/java/org/apache/photark/face/facebook/test/GenericFaceRecognitionTestCase.java
+++ b/photark-face-recognition/src/test/java/org/apache/photark/face/facebook/test/GenericFaceRecognitionTestCase.java
@@ -39,8 +39,8 @@
public class GenericFaceRecognitionTestCase {
private DefaultFaceClient defaultFaceClient;
- private String apiKey = "";
- private String apiSecret = "";
+ private String apiKey = "5ae7a7ddcba07b5d4731930bfe06f4c7";
+ private String apiSecret = "6877f93df2c2bcef2a1ddb6ba26a0d6c";
private static Node node;
diff --git a/photark-ui-admin/src/main/webapp/admin/face.html b/photark-ui-admin/src/main/webapp/admin/face.html
index 14d61d2..d9a5358 100644
--- a/photark-ui-admin/src/main/webapp/admin/face.html
+++ b/photark-ui-admin/src/main/webapp/admin/face.html
@@ -24,6 +24,7 @@
<title>Apache PhotArk - Face Recognition</title>
+ <script type="text/javascript" src="js/constants.js"></script>
<script type="text/javascript" src="../dojo/dojo.js"
djConfig="isDebug:false, parseOnLoad: true, debugAtAllCosts:false"></script>
<script type="text/javascript" src="js/face.js"></script>
@@ -89,7 +90,7 @@
<br>
- <div id="import_submit" class="uploadBtn btn" onClick="">
+ <div id="import_submit" class="uploadBtn btn" onClick="trainUser();">
Train User
</div>
<div id="authFBLabel" align="left"><br/>Before train users, first you should
diff --git a/photark-ui-admin/src/main/webapp/admin/js/face.js b/photark-ui-admin/src/main/webapp/admin/js/face.js
index 4c9d7c5..003678a 100644
--- a/photark-ui-admin/src/main/webapp/admin/js/face.js
+++ b/photark-ui-admin/src/main/webapp/admin/js/face.js
@@ -16,75 +16,109 @@
* specific language governing permissions and limitations
* under the License.
*/
-var facebookUidService;
+var facebookService;
+var genericFaceService;
+var selectFaceApp
+var faceService;
dojo.addOnLoad(function() {
dojo.require("dojo._base.xhr");
dojo.require("dojo.rpc.JsonService");
dojo.addOnLoad(checkAccessTokenRedirect);
dojo.addOnLoad(initView);
+ dojo.addOnLoad(initServices);
});
+function initServices() {
+ faceService = new dojo.rpc.JsonService(photark.constants.FaceRecognitionService);
+ facebookService = new dojo.rpc.JsonService(photark.constants.FacebookFriendFinder);
+}
-function initView(){
- var selectFaceApp = dojo.byId("selectFaceApp");
- selectFaceApp.value = "FaceBook-Friend-Finder";
- dojo.byId("or").style.display = "none";
- dojo.byId("imageFilePath").style.display = "none";
- dojo.byId("imageUrl").style.display = "none";
- dojo.byId("train_label").style.display = "none";
- dojo.byId("authFBLabel").style.display = "";
- dojo.byId("train_uname").style.display = "";
- dojo.byId("import_submit").style.display = "";
+
+function initView() {
+ selectFaceApp = dojo.byId("selectFaceApp");
+ selectFaceApp.value = "FaceBook-Friend-Finder";
+ dojo.byId("or").style.display = "none";
+ dojo.byId("imageFilePath").style.display = "none";
+ dojo.byId("imageUrl").style.display = "none";
+ dojo.byId("train_label").style.display = "none";
+ dojo.byId("authFBLabel").style.display = "";
+ dojo.byId("train_uname").style.display = "";
+ dojo.byId("import_submit").style.display = "";
}
-function manageFields(){
- var selectFaceApp = dojo.byId("selectFaceApp");
- var selectedApp = selectFaceApp.value;
+function manageFields() {
+ selectFaceApp = dojo.byId("selectFaceApp");
+ var selectedApp = selectFaceApp.value;
- if(selectedApp == "General-Face-Recognition") {
- dojo.byId("imageFilePath").style.display = "";
- dojo.byId("imageUrl").style.display = "";
- dojo.byId("train_uname").style.display = "";
- dojo.byId("import_submit").style.display = "";
- dojo.byId("train_label").style.display = "";
- dojo.byId("authFBLabel").style.display = "none";
+ if (selectedApp == "General-Face-Recognition") {
+ dojo.byId("imageFilePath").style.display = "";
+ dojo.byId("imageUrl").style.display = "";
+ dojo.byId("train_uname").style.display = "";
+ dojo.byId("import_submit").style.display = "";
+ dojo.byId("train_label").style.display = "";
+ dojo.byId("authFBLabel").style.display = "none";
- }else if(selectedApp == "FaceBook-Friend-Finder") {
- dojo.byId("or").style.display = "none";
- dojo.byId("imageFilePath").style.display = "none";
- dojo.byId("imageUrl").style.display = "none";
- dojo.byId("train_label").style.display = "none";
- dojo.byId("authFBLabel").style.display = "";
- dojo.byId("train_uname").style.display = "";
- dojo.byId("import_submit").style.display = "";
- }
+ } else if (selectedApp == "FaceBook-Friend-Finder") {
+ dojo.byId("or").style.display = "none";
+ dojo.byId("imageFilePath").style.display = "none";
+ dojo.byId("imageUrl").style.display = "none";
+ dojo.byId("train_label").style.display = "none";
+ dojo.byId("authFBLabel").style.display = "";
+ dojo.byId("train_uname").style.display = "";
+ dojo.byId("import_submit").style.display = "";
+ }
}
-function checkAccessTokenRedirect(){
- var url = window.location.href;
- if(url != "http://localhost:8080/photark/admin/face.html") {
- var accesstoken = url.split("&")[0].split("=")[1];
+function checkAccessTokenRedirect() {
+ var url = window.location.href;
+ if (url != "http://localhost:8080/photark/admin/face.html") {
+ var accesstoken = url.split("&")[0].split("=")[1];
- alert(accesstoken);
-//var s = "https://graph.facebook.com/me?access_token="+accesstoken;
-//var s="http://graph.facebook.com/100000016449363";
- }
- }
+ alert(accesstoken);
+
+ }
+}
function logout() {
window.location = "./logout";
}
function facebookAuth() {
-var url = "https://graph.facebook.com/oauth/authorize?type=user_agent&client_id=224265757599119&redirect_uri=http://localhost:8080/photark/admin/face.html& scope=user_photos,email,user_birthday,user_online_presence,offline_access";
-window.location = url;
+ var url = "https://graph.facebook.com/oauth/authorize?type=user_agent&client_id=151116644958708&redirect_uri=http://localhost:8080/photark/admin/face.html& scope=user_photos,email,user_birthday,user_online_presence,offline_access";
+ window.location = url;
}
+function trainUser() {
+ if (selectFaceApp.value == "General-Face-Recognition") {
+ //TODO call train method in generic face app
+
+ } else if (selectFaceApp.value == "FaceBook-Friend-Finder") {
+ faceService.train("1271543184@facebook.com").addCallback(facebook_ff_callback);
+ }
+
+}
+
+function face_callback(items, exception) {
+ if (exception) {
+ alert("Error");
+ }
+}
+
+function facebook_ff_callback(items, exception) {
+ if (exception) {
+ alert("Error");
+ }
+ alert("AA");
+}
+
+
+
+
diff --git a/photark-ui/src/main/webapp/js/gallery.js b/photark-ui/src/main/webapp/js/gallery.js
index 7feddc7..fe939b7 100644
--- a/photark-ui/src/main/webapp/js/gallery.js
+++ b/photark-ui/src/main/webapp/js/gallery.js
@@ -57,8 +57,6 @@
var permissions = new Array();
var albumImageToBeLoaded = null;
-var FACE_API_KEY = "5ae7a7ddcba07b5d4731930bfe06f4c7";
-var FACE_API_SECRET = "6877f93df2c2bcef2a1ddb6ba26a0d6c";
var facebook_ff;
dojo.addOnLoad(function() {
@@ -97,7 +95,6 @@
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);
facebook_ff = new dojo.rpc.JsonService(photark.constants.FacebookFriendFinder);
}
@@ -279,27 +276,36 @@
}
function showFacebookFriends(){
- facebook_ff.getAllMyFBFriendsInThisPicture().addCallback(facebook_ff_callback);
+ facebook_ff.getAllMyFBFriendsFromPictureLocal("/home/subash/IdeaProjects/pics/friends_2.jpg").addCallback(facebook_ff_callback);
+
+//facebook_ff.getAllMyFBFriendsFromPictureUrl("https://lh4.googleusercontent.com/-rb_m-GQcL00/Ti8sqThvrDI/AAAAAAAAAMY/kUBurbFKJ0A/s640/friends_2.jpg").addCallback(facebook_ff_callback);
+//facebook_ff.getTest("/home/subash/IdeaProjects/pics/friends_2.jpg").addCallback(facebook_ff_callback);
}
function face_callback(items, exception) {
if(exception) {
- // alert(exception.msg);
- displayGallery();
- logout();
- // return;
+ alert("FB AUTH Error");
+
}
+ //alert("FB AUTH OK");
}
+function face_callback1(items, exception) {
+ if(exception) {
+ alert("FB AUTH Error");
+
+ }
+ //alert("FB AUTH OK");
+
+}
+
+
function facebook_ff_callback(items, exception) {
if(exception) {
- // alert(exception.msg);
- displayGallery();
- logout();
- // return;
+ alert("Error");
}
- alert(items[0]);
+ alert(items.length);
}