Ask Your Question

JS's profile - activity

2014-07-31 01:21:20 -0600 asked a question Python location variable issue

Hi, i used an example in OpenCV and tried but halfway through i got an error regarding a location variable that i put into the python script so that i can change the opening/saving the image in a location at will. However i encounter an error as i used c# to pass the location.

image description

image description

when i pass, it doesnt give the exact 2 backslash when i passed it in. Then i tried using 1 forward slash to pass it in , it then again convert to 1 backslash. However, 1 backslash doesnt work.

2014-07-07 03:25:48 -0600 commented question Passing values from c# window form to python script.

Do I place the mouse handler codes in the same python script? So it should pop out a window for me to choose the coordinates so that they will be initiated to the left and right eye coordinates? Thanks!

2014-07-06 21:49:24 -0600 asked a question Passing values from c# window form to python script.

Hi, i am trying to pass values from c# window to python script but i have no clue how. Anyone able to shed some light for this?

  • I am trying to pass int values from textbox into the python script.

// Python script code.

   import sys, math, Image

def Distance(p1,p2):
  dx = p2[0] - p1[0]
  dy = p2[1] - p1[1]
  return math.sqrt(dx*dx+dy*dy)

def ScaleRotateTranslate(image, angle, center = None, new_center = None, scale = None, resample=Image.BICUBIC):
  if (scale is None) and (center is None):
    return image.rotate(angle=angle, resample=resample)
  nx,ny = x,y = center
  sx=sy=1.0
  if new_center:
    (nx,ny) = new_center
  if scale:
    (sx,sy) = (scale, scale)
  cosine = math.cos(angle)
  sine = math.sin(angle)
  a = cosine/sx
  b = sine/sx
  c = x-nx*a-ny*b
  d = -sine/sy
  e = cosine/sy
  f = y-nx*d-ny*e
  return image.transform(image.size, Image.AFFINE, (a,b,c,d,e,f), resample=resample)

def CropFace(image, eye_left=(0,0), eye_right=(0,0), offset_pct=(0.2,0.2), dest_sz = (70,70)):
  # calculate offsets in original image
  offset_h = math.floor(float(offset_pct[0])*dest_sz[0])
  offset_v = math.floor(float(offset_pct[1])*dest_sz[1])
  # get the direction
  eye_direction = (eye_right[0] - eye_left[0], eye_right[1] - eye_left[1])
  # calc rotation angle in radians
  rotation = -math.atan2(float(eye_direction[1]),float(eye_direction[0]))
  # distance between them
  dist = Distance(eye_left, eye_right)
  # calculate the reference eye-width
  reference = dest_sz[0] - 2.0*offset_h
  # scale factor
  scale = float(dist)/float(reference)
  # rotate original around the left eye
  image = ScaleRotateTranslate(image, center=eye_left, angle=rotation)
  # crop the rotated image
  crop_xy = (eye_left[0] - scale*offset_h, eye_left[1] - scale*offset_v)
  crop_size = (dest_sz[0]*scale, dest_sz[1]*scale)
  image = image.crop((int(crop_xy[0]), int(crop_xy[1]), int(crop_xy[0]+crop_size[0]), int(crop_xy[1]+crop_size[1])))
  # resize it
  image = image.resize(dest_sz, Image.ANTIALIAS)
  return image

if __name__ == "__main__":
    image =  Image.open("C:\\Users\\L31101\\Desktop\\test.jpg")
    CropFace(image, eye_left=(34,51), eye_right=(50,52), offset_pct=(0.3,0.3), dest_sz=(92,112)).save("C:\\Users\\L31101\\Desktop\\testcrop.jpg")
  • I am trying to replace the eye_left(34,51) and eye_right(50,52) into new values from my c# window form so that cropping of image can be flexible with different images.
2014-07-01 22:08:50 -0600 asked a question Illumination Normalization cmd error?

image description

Any idea how does this comes about? i tried to run illumination normalization on this.

2014-06-25 20:35:53 -0600 commented question Anyone able to help solve this problem for python script.

okay Thanks alot ! i tried 2 backslashes and it works and yes i i am using manual mouse clicking for cropping and aligning the face.

2014-06-25 02:12:57 -0600 asked a question Anyone able to help solve this problem for python script.

I tried to use this python script for aligning the faces but i faced this error.

image description

2014-06-17 01:08:44 -0600 asked a question How to run python script in visual studio and edit

Hi, i am trying to run a normalization of an image thus, i used a python script to crop the image but how do i get to edit the python script and run it using a visual studio application.

Example: I took a photo of a user and we need to know the location of the eyes thus, the user is able to select his pair of eyes so we can use this to do normalization.

I am not able to do this as i used command prompt to run all the python scripts.

2014-06-13 03:25:29 -0600 received badge  Critic (source)
2014-06-12 22:34:06 -0600 received badge  Editor (source)
2014-06-12 22:32:59 -0600 asked a question Automation of Face recognition

Hi, i am doing a project for facial recognition. I am using python scripts and opencv c++. I am thinking is it possible to open a command window for my python scripts and able to type anything inside using codes. I need this as i used a command window for my python scripts folder to run all of my python scripts. After this step i also require to train models using command window too. So i need to know if this is possible as i searched but to no avail.

I require these as i want to try to make automated as i did everything manually before thus i want to make everything to automate itself.

The Flow :

users are able to come and test the facial recognition and the program will save their face and update into database. The photo will be processed using Normalization and Illumination Normalization and saved into the specific database folder. Therefore, we need everything to be automated like train of models , using normalization, running scripts , doing data analysis from xml to excel sheet.