Dear all,
I am currently attempting to develop an ASP.NET Web Application in Visual Studio Enterprise 2015 using C#.
In this web app, I am supposed to be able to capture personal information (i.e. by filling up some text boxes and drop down lists) and faces (i.e. images of people in .png file format) of people by clicking on the enroll button.
Once the enroll button has be clicked, the inputted personal information will be stored to a database via web service call and the image of interest will be saved to a folder in my local C Drive.
Below is a screenshot of the current user interface I am utilizing. It is rather simple since I am a beginner.
Currently, I can successfully enroll a user's details to the database via a web service I am utilizing to store the images.
However, clicking the Enroll button is also supposed to save a copy of the image of particular interest (i.e. in this case, only the colored picture above). I have tired to do this for some days now and have been unsuccessful in achieving this.
Below, you will see what I currently have coded in the Enroll method:
private void Enroll(string faceID, string imageUrl, string firstname, string lastname, string gender, string birthdate, string ethnicity)
{
var name = string.Format("{0}_{1}", firstname, lastname);
var firstCharOfFirstName = firstname.Substring(0, 1);
//var pid = "";
var pid = string.Concat(firstCharOfFirstName, lastname);
var properties = new List<IdentityData>()
{
new IdentityData("PID", pid),
new IdentityData("Name", name),
new IdentityData("Gender", gender),
new IdentityData("YearOfBirth", birthdate),
new IdentityData("Ethnicity", ethnicity)
};
FaceMatcherManager.Instance.Enroll(faceID, imageUrl, properties); //make a web service call
string imageFileName = Path.GetFileName(imageUrl); //returns e.g. 55.png
try //current code to save image to a folder
{
Bitmap b = new Bitmap(imageUrl);
b.Save(@"C:\Users\SG-VASP\Pictures\WatchList\",System.Drawing.Imaging.ImageFormat.Png);
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.Message);
}
} // close Enroll
protected void Enrollment_DataList_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName.Equals("EnrollFace"))
{
string faceId = e.CommandArgument.ToString(); //contains the folder name
TextBox txtFirstName = (TextBox)(e.Item.FindControl("txtFirstName"));
TextBox txtLastName = (TextBox)(e.Item.FindControl("txtLastName"));
DropDownList genderDropdown = (DropDownList)(e.Item.FindControl("ddlGender"));
DropDownList yobDropdown = (DropDownList)(e.Item.FindControl("ddlYearOfBirth"));
DropDownList ethnicityDropdown = (DropDownList)(e.Item.FindControl("ddlEthnicity"));
var image = (ImageButton)(e.Item.FindControl("Image1"));
var img = image.ImageUrl; //contains the actual image path
var firstName = txtFirstName.Text;
var lastName = txtLastName.Text;
var gender = genderDropdown.SelectedValue;
var birthdate = yobDropdown.SelectedValue;
var ethnicity = ethnicityDropdown.SelectedValue;
this.Enroll(faceId, img, firstName, lastName, gender, birthdate, ethnicity); //pass arguments back to Enroll function
Console.WriteLine();
//faceId e.g. b1933491-11dc-4ff4-9413-a057050cb68d_O5IC4Q0
//img e.g. http://localhost/FaceDetected/b1933491-11dc-4ff4-9413-a057050cb68d_O5IC4Q0/55.png
//firstName e.g. Anders
//lastName e.g. Astrom
//gender e.g. Male
//birthdate e.g. 1979
//ethnicity e.g. Caucasian
}
}
As I run the code above, I get the following error message via a message box:
"uri formats are not supported"
Is there any advise or help that anyone of you may be able to give me?
Warm regards,
Aloysius