-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
task done #1
Open
ajit2704
wants to merge
2
commits into
auviitkgp:master
Choose a base branch
from
ajit2704:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+149
−0
Open
task done #1
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# PROBLEM STATEMENT | ||
|
||
### Input | ||
|
||
This image of a graph,having X and Y axes. | ||
|
||
![alt tag](input.jpg) | ||
|
||
### Desired Output | ||
|
||
Input image + rectangular boxes drawn around the markings on the axes. | ||
|
||
![alt tag](output.jpg) | ||
|
||
### Languages | ||
|
||
C++ / Python | ||
|
||
### Useful tips | ||
|
||
Browse through the OpenCV library documentation and find functions that would be helpful to implement this. | ||
|
||
The basic idea of solution, is to find contours (regions, maybe `rectangular` ones) that have atleast a certain level of text density and are on the left side of Y-axis or below the X-axis. | ||
|
||
Text can be recognised by the sudden change in intensity level with respect to the background. | ||
|
||
But the trick lies in differentiating the X & Y axes from the graph's curve - use Google, StackOverflow and OpenCV tutorials to the maximum extent. | ||
|
||
It may be tough to get all the readings accurately. but it's fine. | ||
|
||
Good luck! | ||
|
||
### Important Note | ||
|
||
Coordinates of the origin of the graph should not be hard-coded specific to a particular image. It should work on any similar graph image with 2 perpendicular lines. | ||
|
||
Variables like cutoff text density can be hard-coded, but it'd be better if the cutoff is dynamically decided. | ||
|
||
### Submission Guidelines | ||
|
||
(1) Fork this repository on GitHub. | ||
|
||
(2) Clone your fork with `git clone` statement. | ||
|
||
(3) Make your local changes, in a sub-directory (say, `graph-detect/<username>/`). | ||
|
||
(4) Push these changes to your fork with `git add`, `git commit` and `git push` statements. | ||
|
||
(5) Create a Pull Request to this repository by comparing across forks with your fork. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Spyder Editor | ||
|
||
This is a temporary script file. | ||
""" | ||
|
||
|
||
import numpy as np | ||
import cv2 | ||
|
||
im = cv2.imread('input.jpg') | ||
im3 = im.copy() | ||
|
||
gray = cv2.cvtColor(im,cv2.COLOR_BGR2GRAY) | ||
blur = cv2.GaussianBlur(gray,(5,5),0) | ||
thresh = cv2.adaptiveThreshold(blur,255,1,1,11,2) | ||
|
||
|
||
|
||
contours,hierarchy = cv2.findContours(thresh.copy(),cv2.RETR_LIST,cv2.CHAIN_APPROX_SIMPLE) | ||
|
||
samples = np.empty((0,100)) | ||
responses = [] | ||
keys = [i for i in range(1,100)] | ||
|
||
for cnt in contours: | ||
if cv2.contourArea(cnt)>50: | ||
|
||
[x,y,w,h] = cv2.boundingRect(cnt) | ||
|
||
if h<11.05: | ||
cv2.rectangle(im,(x,y),(x+w,y+h),(255,0,0),2) | ||
roi = thresh[y:y+h,x:x+w] | ||
roismall = cv2.resize(roi,(10,10)) | ||
cv2.imshow('auv',im) | ||
key = cv2.waitKey(0) | ||
|
||
|
||
if key in keys: | ||
responses.append(int(chr(key))) | ||
sample = roismall.reshape((1,100)) | ||
samples = np.append(samples,sample,0) | ||
|
||
responses = np.array(responses,np.float32) | ||
responses = responses.reshape((responses.size,1)) | ||
print "" | ||
|
||
np.savetxt('generalsamples.data',samples) | ||
np.savetxt('generalresponses.data',responses) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Spyder Editor | ||
|
||
This is a temporary script file. | ||
""" | ||
|
||
|
||
import numpy as np | ||
import cv2 | ||
|
||
im = cv2.imread('input.jpg') | ||
im3 = im.copy() | ||
|
||
gray = cv2.cvtColor(im,cv2.COLOR_BGR2GRAY) | ||
blur = cv2.GaussianBlur(gray,(5,5),0) | ||
thresh = cv2.adaptiveThreshold(blur,255,1,1,11,2) | ||
|
||
|
||
|
||
image,contours,hierarchy = cv2.findContours(thresh.copy(),cv2.RETR_LIST,cv2.CHAIN_APPROX_SIMPLE) | ||
|
||
samples = np.empty((0,100)) | ||
responses = [] | ||
keys = [i for i in range(1,100)] | ||
|
||
for cnt in contours: | ||
if cv2.contourArea(cnt)>50: | ||
|
||
[x,y,w,h] = cv2.boundingRect(cnt) | ||
|
||
if h<11.05: | ||
cv2.rectangle(im,(x,y),(x+w,y+h),(255,0,0),2) | ||
roi = thresh[y:y+h,x:x+w] | ||
roismall = cv2.resize(roi,(10,10)) | ||
cv2.imshow('auv',im) | ||
key = cv2.waitKey(0) | ||
|
||
|
||
if key in keys: | ||
responses.append(int(chr(key))) | ||
sample = roismall.reshape((1,100)) | ||
samples = np.append(samples,sample,0) | ||
|
||
responses = np.array(responses,np.float32) | ||
responses = responses.reshape((responses.size,1)) | ||
print "" | ||
|
||
np.savetxt('generalsamples.data',samples) | ||
np.savetxt('generalresponses.data',responses) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have a look at documentation of the
findContours()
function