Get the contents of an array into php

I am having problems getting information out of relatives concerning people in photos for a family tree. So I am trying to make things easier for them hoping it will get them to supply the names!

I have found a nice piece of Javascript that as far as I have tested will find the faces and I want to use it to crop faces out of photos: http://facedetection.jaysalvat.com/

Going off track a bit my first idea ws to have the user click on a face and a text box would open. They could then type the name into the box but as far as I can see I would need to setup a imagemap for every photo.
Doing it the new way I can use a bit of php and create a page for every photo in a folder.

Anyway my workflow will be:
Upload an image.
Run some php which would feed the photo name into the Javascript.
Get the dimensions from the JavaScript and crop out the faces with php.
Create a text box for every face with the cropped face next to the box so there is no confusion as to which face we are dealing with.
When the form is submitted it would send me an email.

The problem I currently have is the Jquery code is saving the dimensions into an array which I can see in the Firefox consol:
Array [ Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, 4 more… ]

Each object contains something like:
confidence:-0.34431988999999996
height:30.118475189239156
neighbors:2
offsetX:1381.470260262376
offsetY:346.404017134476
positionX:729.9702602623761
positionY:109.73734538154636
scaleX:0.75
scaleY:0.750965250965251
width:30.118475189239156
x:729.9702602623761
y:109.73734538154636
proto:Object

Can somebody tell me how I can either pass the array directly to php or save each object array into a file I can then read into php.

Hey Rubble,

How goes it?
Do I understand you correctly that you have an array of JavaScript objects and you want to pass them to a PHP script running on the server?

If so, then you could use AJAX. If this is what you are trying to do, I could provide an example.

Please can you hold off on this for the moment Pullo - I am looking into the code from the person that wrote the algorithm and it seems better for what I want.

Yes you are correct Pullo.

I an looking to collect the dimensions that outline the face which I assume are offsetx, offsety, height and width.

With these I can create a crop command with Imagemagick to crop out the faces that I will then use in my form.

Yeah, no problem.
Just let me know when you’re ready.

The new example is completely JavaScript without Jquery - as far as I can tell - and works in different way. I am not getting any output in my Firefox consol.

I have found the function that draws the circle on the faces and I assume I can get some data from there?

for (var i = 0; i < comp.length; i++) {
ctx.beginPath();
ctx.arc((comp[i].x + comp[i].width * 0.5) * scale, (comp[i].y + comp[i].height * 0.5) * scale,(comp[i].width + comp[i].height) * 0.25 * scale * 1.5, 0, Math.PI * 2);
ctx.stroke();
			}

It looks like I need comp[i].x, comp[i].y, comp[i].width, comp[i].height Although I could be barking up the wrong tree!

This is the new page I am working from: http://liuliu.me/ccv/js/nss/

Could you post of PM me a link where I can see this not working?

Thank you for the help @James_Hibbard
For the record the code I am have is using “workers” for threading and so instead of getting one multidimensional array I get multiple arrays that I intend to save into a file with php. I can then get the contents of the file for further processing. This was done using AJAX and Jquery:

var face = "face_" + (i + 1);
$.ajax({
  url: 'submit.php',
  type: 'POST',
  dataType: 'html',
  data: {params: [face, xPos, yPos, tops, side]},
})
.done(function(res) {
  console.log(res);
})
.fail(function() {
  console.log("error");
});

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.