Spot the Difference Game
Overview
- Term project in Embedded Vision course (Undergraduate)
- Application of Image Processing with using OpenCV
- If you want more information about its source code, visit my Github
Idea
- For easy control, this program is based on mouse-click actions
- Contours detection is the main function in this program process
Description
- Have 3 levels of difficulty, Hard-Normal-Easy
- Time limit is depend on the level of difficulty
- Contours Detection
- Use 3 OpenCV methods
cvAbsDiff()cvFindContours()cvDrawContours()
- More information about these 3 methods, refer some documentation sites
- Use 3 OpenCV methods
cvAbsDiff()
- Format
cvAbsDiff(CvArr* src1, CvArr* src2, CvArr* dst)
- Function
- Solve the absolute value from the difference between
src1andsrc2(matrix form) - Put the solved absolute value in
dstvariable - For this program, this method solves the difference value between original image and manipulated image
- Solve the absolute value from the difference between
cvFindContours()
- Format
cvFindContours(CvArr* image, CvMemStorage* storage, CvSeq** firstContour, int headerSize = sizeof(CvContour), int mode = CV_RETR_LIST, int method = CV_CHAIN_APPROX_SIMPLE, CvPoint offset = cvPoint(0,0))
- Function
- Find the number of contours in binary image (Convert from input image)
- Return variable (sequence),
firstContouris the outermost contour - For this program, this method solves the contours from the result image of cvAbsDiff() method
- Parameters
image- Input image (original), must be 8-bit single channel image(Binary Image)
storage- Memory that searched contours are saved in
firstContour- The pointer of the outermost contour
headerSize- Size of Sequence Header
modeCV_RETR_EXTERNALCV_RETR_LISTCV_RETR_CCOMPCV_RETR_TREE
methodCV_CHAIN_CODECV_CHAIN_APPROX_NONECV_CHAIN_APPROX_SIMPLECV_CHAIN_APPROX_TC89_L1, CV_CHAIN_APPROX_TC89_KCOSCV_LINK_RUNS
offset
cvDrawContours()
- Format
cvDrawContours(CvArr* img, CvSeq* contour, CvScalar external_color, CvScalar hole_color, int max_level, int thickness = 1, int lineType = 8)
- Function
- Draw the contours from
CvSeq* contour - Differentiate exterior or hole before drawing
- For this program, this method draws the contours from the result of cvFindContours() method
- Draw the contours from
- Parameters
imagecontour- Contours information from
cvFindContours()method
- Contours information from
external_colorhole_colormax_levelthicknesslineType
Result
-
Game start & Setting levels difficulty
Game Start
Level difficulty -
Game play screen
Game Play - Inital mode
Game Play - Running mode -
Game clear & over
Game Clear
Game Over
Development Environment
- Visual Studio 2017 (C++ language)
- OpenCV
Leave a comment