mirror of
https://github.com/arnaucube/objectImageIdentifierAI.git
synced 2026-02-07 11:46:55 +01:00
jupyter book cleaned, started the upload of the images in the smartphone app
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
var urlapi = "http://127.0.0.1:3200/";
|
||||
|
||||
angular.module('app', [
|
||||
'ionic',
|
||||
@@ -35,7 +36,8 @@ angular.module('app', [
|
||||
url: '/main',
|
||||
views: {
|
||||
'menuContent': {
|
||||
templateUrl: 'templates/main.html'
|
||||
templateUrl: 'templates/main.html',
|
||||
controller: 'MainCtrl'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,5 +1,80 @@
|
||||
angular.module('app.main', [])
|
||||
|
||||
.controller('MainCtrl', function($scope) {
|
||||
.controller('MainCtrl', function($scope, $http) {
|
||||
$scope.response = "";
|
||||
$scope.model_file={};
|
||||
|
||||
$scope.uploadFile = function() {
|
||||
console.log("$scope.img_file");
|
||||
console.log($scope.img_file);
|
||||
var fd = new FormData();
|
||||
//Take the first selected file
|
||||
fd.append("file", $scope.img_file);
|
||||
console.log(fd);
|
||||
$http({
|
||||
url: urlapi + 'predict',
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": undefined
|
||||
},
|
||||
data: fd
|
||||
})
|
||||
.then(function(data) {
|
||||
console.log("response: ");
|
||||
console.log(data.data);
|
||||
// response reaction
|
||||
$scope.response= data.data.result;
|
||||
},
|
||||
function(response) { // optional
|
||||
// failed
|
||||
console.log(response);
|
||||
});
|
||||
};
|
||||
|
||||
});
|
||||
/*$scope.takePhoto = function() {
|
||||
alert("a");
|
||||
console.log("take photo");
|
||||
var options = {
|
||||
quality: 100,
|
||||
destinationType: Camera.DestinationType.DATA_URL,
|
||||
sourceType: Camera.sourceType,
|
||||
allowEdit: true,
|
||||
encodingType: Camera.EncodingType.PNG,
|
||||
targetWidth: 500,
|
||||
targetHeight: 500,
|
||||
popoverOptions: CameraPopoverOptions,
|
||||
saveToPhotoAlbum: false,
|
||||
correctOrientation:true
|
||||
};
|
||||
|
||||
$cordovaCamera.getPicture(options).then(function(imageData) {
|
||||
//$scope.user.newAvatar = "data:image/jpeg;base64," + imageData;
|
||||
$scope.img.imgdata = "data:image/jpeg;base64," + imageData;
|
||||
$scope.img.img = imageData;
|
||||
}, function(err) {
|
||||
console.log(err);
|
||||
});
|
||||
};*/
|
||||
})
|
||||
.directive('fileModel', [
|
||||
'$parse',
|
||||
function($parse) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function(scope, element, attrs) {
|
||||
var model = $parse(attrs.fileModel);
|
||||
var modelSetter = model.assign;
|
||||
|
||||
element.bind('change', function() {
|
||||
scope.$apply(function() {
|
||||
if (attrs.multiple) {
|
||||
modelSetter(scope, element[0].files);
|
||||
} else {
|
||||
modelSetter(scope, element[0].files[0]);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
]);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<ion-content>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="button button-full button-stable">
|
||||
<div ng-click="takePhoto()" class="button button-full">
|
||||
<i class="icon ion-camera"></i> Take Photo
|
||||
</div>
|
||||
</div>
|
||||
@@ -12,14 +12,19 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<input type='file' file-model='img_file'>
|
||||
|
||||
<div class="list card">
|
||||
<div class="item item-image">
|
||||
<img src="http://www.trueactivist.com/wp-content/uploads/2015/07/hotdog-300x300.jpg">
|
||||
<img ng-src="{{img_file}}">
|
||||
</div>
|
||||
<a class="item item-icon-left balanced" href="#">
|
||||
<div ng-click="uploadFile()" class="button button-royal" href="#">
|
||||
Send
|
||||
</div>
|
||||
</div>
|
||||
<a ng-show="response!=''" class="item item-icon-left balanced" href="#">
|
||||
<i class="icon ion-checkmark"></i>
|
||||
Is a Hotdog
|
||||
Is a {{response}}
|
||||
</a>
|
||||
</div>
|
||||
</ion-content>
|
||||
|
||||
Reference in New Issue
Block a user