Category Archives: Projects

Yono – Period Tracking

Updating of the calendar’s view for given Changing Status

The MeStatusViewController needs to communicate with CalendarViewController whenever a user has changed status. We do this by notifications because we are communicating ViewController to ViewController in a MVC setting.

MeStatusViewController

Once an update is notified by MeStatusViewController, we call CalendarViewcontroller’s updateCalendarView using previously saved period history.

CalendarViewcontroller

When we update the calendar, notice we get the status of the app. Hence we’ll either get “Period Tracking” or “Trying to Conceive”. We process the period dates according to either these status.

CalendarViewcontroller

iCarousel dates

The dates on the iCarousel, is calculated this way:

component setDay to -365 and then uses dateByAddingComponents:toDate: will generate a NSDate 365 days prior to today.
For example, if today is 5/22/15, then the result would be 5/22/14
-364 5/23/14
-363 5/24/14
…all the way until we have one full year of nsdates from 5/23/14 to 5/22/15.
As each date is generated, we insert it into daysCarouselDictionary.

daysCarouselDictionary is used in iCarousel delegate methods for data display.

We generate 2 years of dates, where today is smack in the middle.
Hence continuing from previous example, we then generate a future year
1 5/24/15
2 5/25/15
….
365 5/22/16

Thus, that is how we fill the iCarousel with those perspective dates.

Coloring of the period dates

CalendarViewController.m

Flow Dates ( period dates )

Taking in flow dates and updating your Calendar

The app starts and the user presses on the flow dates button on the top right.
User enters 2 different flow dates and clicks on “Save History” on the top left.

PeriodHistoryViewController’s “Save History” is a back button. Its responder is:

After the user selects the average cycle length we hit:

Then it goes to MainTabsViewController’s

Then, CalendarViewController’s

Holistic Element

Holistic Element for the iPad is a lifestyle app that connect its users to the power and joy of healthy living and a balanced lifestyle. The app strives to help users get started in basic traditional cooking, easy interval exercises that they will love to do daily, and articles that educate them in health.

Basically there are 3 sections: education, cooking, and exercises.

Education is basically a professionally well written article with references for further reading.

he_drummer

Cooking involves instructing the user how to cook via a video and image tutorial.

he_cooking

he_eggs_shrimp

he_detail_cook

Same goes for exercises.
In additional, for exercises, there is a timer workout program that the user can use in their living room.

he_exercises

he_push_up

Face Recognizer using openCV on the iPad

Note:

This project was built using

  • openCV 2.4.8
  • xCode 5.0.2
  • for iOS 7
  • iPad air

set up instructions here
download the full source here (26.9MB)

I created 2 sections. The recognition screen and the registration screen.

face_demo_welcomeWe first start off on the main page.

In the MainMenuViewController, I have 2 variables:

  • CameraWrapper * cameraWrapper;
  • DataModel * dataModel;

The cameraWrapper is basically an object that wraps all the functionality of the openCV camera. What it does it it captures an image repeatedly. Each image is a matrix object cv::Mat. It gets passed to you, and it is up to you to process it, see where the detected face is, and do things to it.

The dataModel holds all the face data structures. Namely, we are trying to save all the user faces into this data structure. We also have a user labels data structure that matches the faces. Finally it has a UpdateViewDelegate that calls whatever UIViewController that conforms to this delegate to update its front end whenever something gets updated int our data model.

For the register view controller, we add faces we’ve detected to our carousel. That way whenever a system has finished collecting user’s faces, it can train it, and thus, be able to recognize the user in the future.

In the case of recognition, our UpdateViewDelegate is all about updating user interface items.

When you push the registration button you open up a UIViewController to register your face.

When you push the recognition button you open up a UIViewController to recognize your face.

Both views repeatedly detect your face.

Face Detection and 2 ways of facial lighting

I’ve used 2 main methods of getting different lighting of the face. For example, one way it to have the user move their face around by controlling the position of their nose with a axis and a yellow dot. Have their nose line up with the yellow dot and then you’ll be able to position their face differently. Thus, you’ll get different facial lighting and thus, our training image set can be much more various. This helps in the recognition phase.

A second way is to use accelerometer. Have the user stand in one spot and snap images from 0 – 360 degrees. That way, you will also get various lighting on the user’s facial structures.

Camera leak…fix and usage

In openCV’s module highhui folder, go to cap_ios_abstract_camera.mm file
i.e, /Users/rickytsao/opencv-2.4.8/modules/highgui/src/cap_ios_abstract_camera.mm
and replace the stop method with this:

Insert the lines where I have (++). This is where we need to release the captureSession one more time. Or else, you will leak memory when you opens and closes the camera one too many times.

Step 1, process the face

Whether we are in registration or recognition, the program is constantly detecting a subject’s face via the method ProcessFace.

Every time camera from the iPad captures an image, it gets passed into our Processface method here. That image is of object Mat.

The method getPreprocessedFace will return the preprocessedFace, which means whether it has detected a valid face or not. Then we see what phase we are in and do recognition, or collect. In our case, since it is registration, we are collecting faces. So whatever face we detect, will be saved into a data structured to be trained later.

As of now, we are collecting face so we use the MODE_COLLECT_FACES phase. This is where we for each image we snap, we inserted it into a data structure called preprocessedFaces.

Before the insertion, we do 3 things to the image. We shrink it to 70×70. Grayscale it. And equalize it. That way, the size of our image is much smaller and easier to work with. Then we pass it into openCV’s detectMultiScale, and it will return a cv::Rect object, detailing, where the face(s) is on the screen. In our case, we are working only with one face. We detect the largest face on the current image.

Then we draw a square around the face.

Once that’s done, we then see what phase we are in:

  • MODE_RECOGNITION
  • MODE_TRAINING
  • MODE_COLLECT_FACES

Since we are in MODE_COLLECT_FACES, we push our image matrix into a data structure.

detect_save_faces

I used iCarousel to add all the images I took and insert them onto an image carousel. That way, we can scroll through and check out all the images we took. These are the images that were added into our preprocessedFaces data structure.

Also, in previous versions, I simply used the yellow circle to match up to the person’s nose. Thus, angling their face JUST a little so that I can collect different angles of their face. In this version, I use the accelerometer, where the user angles their faces horizontally from 0 to 360.

Training

face_detect_me

After the faces have been collected, we automatically train those images using
method learnCollectedFacesWithFaces:withLabels:andStrAlgorithm: in DataModel.m.

We train it on a cv::Ptr object. Once its trained, we can recognize it by having the phase be changed to recognize in DataModel.m. Once our phase change to recognition, we run the below method, and use

to predict which image matrix below to which identity.

face_detect_zhuyu