From b4e04ac4ab9e6717b9dd60f2181dce911deabce6 Mon Sep 17 00:00:00 2001 From: Aczopek Date: Thu, 21 Apr 2016 10:56:20 -0500 Subject: [PATCH 01/17] Added files via upload From 31f79741eaa134fa23b1817a316c2077ad8d1e70 Mon Sep 17 00:00:00 2001 From: Aczopek Date: Thu, 21 Apr 2016 10:56:51 -0500 Subject: [PATCH 02/17] Added files via upload From 1f6f2085e0ba9342804b474e42f28907d41be033 Mon Sep 17 00:00:00 2001 From: Aczopek Date: Thu, 21 Apr 2016 10:57:22 -0500 Subject: [PATCH 03/17] Added files via upload --- quizAngular/app/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quizAngular/app/index.html b/quizAngular/app/index.html index c4d4f32..87fe933 100755 --- a/quizAngular/app/index.html +++ b/quizAngular/app/index.html @@ -59,7 +59,7 @@

IPRO 207 Interactive ExercisesFrom Physical Ball and Stick to Computer
  • Nomenclature
  • Stereochemistry
  • Reactions
  • -
  • Easy Quiz
  • +
  • Easy Exercises
  • From b3c74f140ab5853fd6675c8635a19dbf7125c05b Mon Sep 17 00:00:00 2001 From: Aczopek Date: Thu, 21 Apr 2016 10:58:05 -0500 Subject: [PATCH 04/17] Added files via upload --- quizAngular/dist/index.html | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/quizAngular/dist/index.html b/quizAngular/dist/index.html index 3f2105b..14d6e6b 100755 --- a/quizAngular/dist/index.html +++ b/quizAngular/dist/index.html @@ -1,6 +1,12 @@ - + + + +

    IPRO 207 Quiz App From Physical Ball and Stick to Computer Models of Chemical Systems

    +

    IPRO 207 Interactive Excercise App From Physical Ball and Stick to Computer Models of Chemical Systems

    + +

    {{hint}}

    + +


    Instructions
    @@ -19,7 +24,7 @@

    {{question}}

    - +
    Correct! Incorrect :(
    diff --git a/quizAngular/dist/views/template2.html b/quizAngular/dist/views/template2.html index 6b3264e..1aebeb8 100755 --- a/quizAngular/dist/views/template2.html +++ b/quizAngular/dist/views/template2.html @@ -5,7 +5,11 @@

    {{question}}

    -

    {{hint}}

    + + +

    {{hint}}

    + +
    • @@ -29,7 +33,7 @@

      {{question}}

    -
    +
    Correct! Incorrect :(
    diff --git a/quizAngular/dist/views/template3.html b/quizAngular/dist/views/template3.html index 85729d2..4b9d008 100755 --- a/quizAngular/dist/views/template3.html +++ b/quizAngular/dist/views/template3.html @@ -15,7 +15,12 @@
    -

    {{question}}

    {{hint}}

    +

    {{question}}

    + + +

    {{hint}}

    + +

    @@ -34,7 +39,7 @@

    {{question}}

    {{hint}}

    -
    +
    Correct! Incorrect :(

    Quiz is over. Score: {{score}}

    diff --git a/quizAngular/dist/views/template4.html b/quizAngular/dist/views/template4.html index 78d7d3d..a5c9470 100755 --- a/quizAngular/dist/views/template4.html +++ b/quizAngular/dist/views/template4.html @@ -15,7 +15,12 @@
    -

    {{question}}

    {{hint}}

    +

    {{question}}

    + + +

    {{hint}}

    + +
    @@ -43,7 +48,7 @@

    {{question}}

    {{hint}}

    -
    +
    Correct! Incorrect :(
    From d3c91d159f90546a680cdc1e092819d39d8e7441 Mon Sep 17 00:00:00 2001 From: Aczopek Date: Thu, 21 Apr 2016 13:54:43 -0500 Subject: [PATCH 07/17] Added files via upload --- quizAngular/dist/scripts/scripts.e8e4d888.js | 168 ++++++++++++++++++- 1 file changed, 167 insertions(+), 1 deletion(-) diff --git a/quizAngular/dist/scripts/scripts.e8e4d888.js b/quizAngular/dist/scripts/scripts.e8e4d888.js index 316093c..4984eb9 100755 --- a/quizAngular/dist/scripts/scripts.e8e4d888.js +++ b/quizAngular/dist/scripts/scripts.e8e4d888.js @@ -1 +1,167 @@ -"use strict";function quiz(a){return{restrict:"AE",scope:{},templateUrl:"views/template.html",link:function(b,c,d){b.start=function(){b.id=0,b.quizOver=!1,b.inProgress=!0,b.getQuestion()},b.reset=function(){b.inProgress=!1,b.score=0},b.getQuestion=function(){var c=a.getQuestion(b.id),d=a.setSize;c?(b.type=c.type,b.question=c.question,b.options=c.options,b.answer=c.answer,b.imgs=c.imgs,b.answerMode=!0,$("textarea").val(""),$("input:radio:checked").prop("checked",!1),$(".progress-bar").css("width",b.id/d*100+"%")):b.quizOver=!0},b.checkAnswer=function(){switch(b.type){case"0":if(!$("input[name=answer]:checked").length)return;var a=$("input[name=answer]:checked").val();a===b.options[b.answer]?(b.score++,b.correctAns=!0):b.correctAns=!1;break;case"1":var a=$("textarea").val();if(!a.length)return;a===b.answer?(b.score++,b.correctAns=!0):b.correctAns=!1;break;case"3":if(console.log("SMILES is"+SMILES),!SMILES)return;b.answer===SMILES?(b.score++,b.correctAns=!0):b.correctAns=!1}b.answerMode=!1},b.nextQuestion=function(){b.id++,b.getQuestion()},b.reset()}}}function quizFactory(){var a=[{type:"0",question:"Select a correct IUPAC name for the structure below.",options:["2-iodo-4-ethyl-4-methylpentane","3,3-dimethyl-5-iodohexane","2-iodo-4,4-dimethylhexane","2-ethyl-2-methyl-4-iodopentane"],imgs:"1.PNG",answer:2},{type:"0",question:"Select a correct IUPAC name for the structure below.",options:["1-ethyl-1-isopropylhexane","2-methyl-3-ethyloctane","3-ethyl-2-methyloctane","2-methyl-3-pentylpentane"],imgs:"2.PNG",answer:2},{type:"0",question:"Select a correct IUPAC name for the structure below.",options:["2-methyl-3-ethylheptane","3-butyl-2-methylpentane","3-ethyl-2-methylheptane","5-isopropylheptane"],imgs:"3.PNG",answer:2},{type:"1",question:"Name the following compound according to the IUPAC system",options:[],imgs:"4.PNG",answer:"2-ethyl-1,1-dimethylcyclopropane"},{type:"1",question:"Name the following compound according to the IUPAC system",options:[],imgs:"6.PNG",answer:"3-ethyl-2-methylpentane"},{type:"3",question:"Build ethanol.",options:[],imgs:"",answer:"CCO"},{type:"3",question:"Build 5-ethyl-2,3,4-trimethylheptane.",options:[],imgs:"",answer:"CCC(CC)C(C)C(C)C(C)C"},{type:"3",question:"Build 2-chlorobutane.",options:[],imgs:"",answer:"CCC(C)Cl"},{type:"3",question:"Build 2-ethylthiobutane.",options:[],imgs:"",answer:"CCSC(C)CC"},{type:"3",question:"Build 1-methoxybutane.",options:[],imgs:"",answer:"CCCCOC"}];return{setSize:a.length,getQuestion:function(b){return b Date: Thu, 21 Apr 2016 16:16:19 -0500 Subject: [PATCH 08/17] Added files via upload --- quizAngular/dist/scripts/scripts.e8e4d888.js | 53 ++++++++++++++------ 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/quizAngular/dist/scripts/scripts.e8e4d888.js b/quizAngular/dist/scripts/scripts.e8e4d888.js index 4984eb9..60adef9 100755 --- a/quizAngular/dist/scripts/scripts.e8e4d888.js +++ b/quizAngular/dist/scripts/scripts.e8e4d888.js @@ -111,21 +111,45 @@ var a=$("input[name=answer]:checked").val();a===b.options[b.answer]?(b.score++,b case"1":var a=$("textarea").val();if(!a.length)return;a===b.answer?(b.score++,b.correctAns=!0):b.correctAns=!1;break; case"3":if(console.log("SMILES is"+SMILES),!SMILES)return;b.answer===SMILES?(b.score++,b.correctAns=!0):b.correctAns=!1} b.answerMode=!1},b.nextQuestion=function(){b.id++,b.getQuestion()},b.reset()}}} +function shuffle(array) { + var currentIndex = array.length, temporaryValue, randomIndex; + + // While there remain elements to shuffle... + while (0 !== currentIndex) { + + // Pick a remaining element... + randomIndex = Math.floor(Math.random() * currentIndex); + currentIndex -= 1; + + // And swap it with the current element. + temporaryValue = array[currentIndex]; + array[currentIndex] = array[randomIndex]; + array[randomIndex] = temporaryValue; + } + + return array; +} + function quizFactory4() {var a=[ -{type:"3",question:"Build the molecule that does NOT contain carbon atoms: A) Water B) Propane C) Carbonite ",options:[],imgs:"",answer:"",hint:"hint",}, -{type:"3",question:"Build a Dihydrogen Monoxide molecule.",options:[],imgs:"",answer:"DHMO",hint:"hint",}, -{type:"3",question:"A Cyclohexane molecule consists of 6 carbons that form a hexagon shape. Build a Cyclopentane molecule.",options:[],imgs:"",answer:"C1CCCCC1",hint:"hint",}, -{type:"3",question:"Build the molecule that is an alcohol: A) Ethane B)Ethene C)Ethanol (pictures shown?)",options:[],imgs:"",answer:"",hint:"hint",}, -{type:"3",question:"Build the molecule that is an alkane: A) Ethane B)Ethene C)Ethanol (pictures shown?)",options:[],imgs:"",answer:"",hint:"hint",}, -{type:"3",question:"Build a Carbon Dioxide molecule (Assume single bond piece represents double bond)",options:[],imgs:"",answer:"CO2",hint:"hint",}, -{type:"3",question:"Build a Hydrogen Peroxide molecule.",options:[],imgs:"",answer:"H2O2",hint:"hint",}, -{type:"3",question:"Build an Octane molecule.",options:[],imgs:"",answer:"C8H18",hint:"hint",}, -{type:"3",question:"Build a Hydrogen Molecule.",options:[],imgs:"",answer:"H",hint:"hint",}, -{type:"3",question:"2 molecules of H2O were formed by combining 2 molecules of H2 and 1 molecule of X. Build this molecule.",options:[],imgs:"",answer:"CCC(CC)C(C)C(C)C(C)C",hint:"hint"}] -;return{setSize:a.length,getQuestion:function(b) -{return b<3?a[Math.floor(Math.random() * a.length)]:!1}}} -/*{return b Date: Thu, 21 Apr 2016 16:26:44 -0500 Subject: [PATCH 09/17] arrays get shuffled for mixing up the questions --- quizAngular/dist/scripts/scripts.e8e4d888.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/quizAngular/dist/scripts/scripts.e8e4d888.js b/quizAngular/dist/scripts/scripts.e8e4d888.js index 60adef9..a54a26c 100755 --- a/quizAngular/dist/scripts/scripts.e8e4d888.js +++ b/quizAngular/dist/scripts/scripts.e8e4d888.js @@ -34,6 +34,7 @@ function quizFactory() {type:"3",question:"Build 2-chlorobutane.",options:[],imgs:"",answer:"CCC(C)Cl",hint:"hint",}, {type:"3",question:"Build 2-ethylthiobutane.",options:[],imgs:"",answer:"CCSC(C)CC",hint:"hint",}, {type:"3",question:"Build 1-methoxybutane.",options:[],imgs:"",answer:"CCCCOC",hint:"hint",}]; +shuffle(a); return{setSize:a.length,getQuestion:function(b){return b Date: Thu, 21 Apr 2016 16:30:55 -0500 Subject: [PATCH 10/17] Added files via upload --- quizAngular/dist/views/template2.html | 2 +- quizAngular/dist/views/template3.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/quizAngular/dist/views/template2.html b/quizAngular/dist/views/template2.html index 1aebeb8..533f4dd 100755 --- a/quizAngular/dist/views/template2.html +++ b/quizAngular/dist/views/template2.html @@ -8,7 +8,7 @@

    {{question}}

    {{hint}}

    - +
      diff --git a/quizAngular/dist/views/template3.html b/quizAngular/dist/views/template3.html index 4b9d008..5d2696e 100755 --- a/quizAngular/dist/views/template3.html +++ b/quizAngular/dist/views/template3.html @@ -19,7 +19,7 @@

      {{question}}

      {{hint}}

      - +
      From 8228e10700e079d69c29e62d70894149dbb1df0b Mon Sep 17 00:00:00 2001 From: Aczopek Date: Thu, 21 Apr 2016 16:37:34 -0500 Subject: [PATCH 11/17] removed shuffle from second tab --- quizAngular/dist/scripts/scripts.e8e4d888.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quizAngular/dist/scripts/scripts.e8e4d888.js b/quizAngular/dist/scripts/scripts.e8e4d888.js index a54a26c..27d6c1f 100755 --- a/quizAngular/dist/scripts/scripts.e8e4d888.js +++ b/quizAngular/dist/scripts/scripts.e8e4d888.js @@ -72,7 +72,7 @@ function quizFactory2() {type:"1",question:"What is the configuration of the following molecule?",options:[],imgs:"20-9.PNG",answer:"R"}, {type:"1",question:"What is the configuration of the following molecule?",options:[],imgs:"20-10.PNG",answer:"R"}, {type:"1",question:"What is the configuration of the following molecule?",options:[],imgs:"20-11.PNG",answer:"R"}]; -shuffle(a); + return{setSize:a.length,getQuestion:function(b){return b Date: Fri, 22 Apr 2016 06:53:46 -0500 Subject: [PATCH 12/17] just updated some things how you have it to make them not conflict --- Live-LeastWorkingModel.py | 57 +++------ leastWorkingModel.py | 252 +++++++++++++++++++++++++++++++------- 2 files changed, 223 insertions(+), 86 deletions(-) diff --git a/Live-LeastWorkingModel.py b/Live-LeastWorkingModel.py index 2130e82..5b5b22b 100644 --- a/Live-LeastWorkingModel.py +++ b/Live-LeastWorkingModel.py @@ -2,14 +2,12 @@ import numpy as np import sys import math -import cirpy -import Visualization.query as query def printHelpText(): print 'Welcome to our Least Working Program for IPRO 207 in Spring 2016' #End Function printHelpText() -def distance3D(x,y): +def distance3D(x,y): return ((1.0*x[0]-y[0])**2+(1.0*x[1]-y[1])**2+(1.0*x[2]-y[2])**2)**(0.5) #End Function distance() def distance2D(x,y): @@ -43,14 +41,14 @@ def nearestNeighbor(colors, pixel): d=distance3D(pixel, c) if dist==-1 or d5*c1[2] or distance>5*c2[2]: return False + if distance>4*c1[2] or distance>4*c2[2]: return False STEPS =25 PERCENT_SKIP=0.3 THRESHOLD=0.85 @@ -58,12 +56,10 @@ def detectSingleBond(image, c1, c2): p2 = c2*PERCENT_SKIP + c1*(1-PERCENT_SKIP) direction = p2-p1 count=0 - print 'STARTINGS' for i in range(STEPS): step = direction*i/STEPS test = p1 + step - print image[math.floor(test[1])][math.floor(test[0])] - if abs(distance3D(image[math.floor(test[1])][math.floor(test[0])], [185,135,135]))<45: + if abs(distance3D(image[math.floor(test[1])][math.floor(test[0])], [190,150,155]))<45: count = count+1 return count>THRESHOLD #End Function detectSingleBond() @@ -80,7 +76,7 @@ def DFS(graph, vertexNames): EDGE_REMOVAL_COUNTER=0 removeCycles(graph,vertexNames,seen,start,None) ret='' - seen = [False]*len(graph) + seen = [False]*len(graph) return recursiveDFS(graph, vertexNames, seen, start, None) #End Function DFS(graph, vertexNames) @@ -127,13 +123,13 @@ def recursiveDFS(graph, vertexNames, seen, cur, parent): return ret #End Function recursiveDFS(graph, vertexNames, seen, cur) -cap = cv2.VideoCapture(0) -cv2.namedWindow('Ball And Stick Tracker',cv2.WINDOW_AUTOSIZE) +cap = cv2.VideoCapture(1) +cv2.namedWindow('Ball And Stick Tracker',cv2.CV_WINDOW_AUTOSIZE) printHelpText() -COUNTER=27 +COUNTER=50 quit=False while not quit: retval,image = cap.read() @@ -147,13 +143,13 @@ def recursiveDFS(graph, vertexNames, seen, cur, parent): image = cv2.medianBlur(image,3) cimg = image.copy() img = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY) - circles = cv2.HoughCircles(img,cv2.HOUGH_GRADIENT,1,30, - param1=50,param2=35,minRadius=15,maxRadius=50) + circles = cv2.HoughCircles(img,cv2.cv.CV_HOUGH_GRADIENT,1,30, + param1=45,param2=25,minRadius=15,maxRadius=40) if circles!=None: circles = np.uint16(np.around(circles)) - atomNames = ['C', 'O', 'N','P','H','C6'] - colorNames = ['Black', 'Red', 'Blue','Purple','White','Benzene'] - color = [[34,27,25], [70,25,155], [210,125,75], [165,80,95], [245,175,185],[55,85,80]] + atomNames = ['C', 'O', 'N','P','H','F'] + colorNames = ['Black', 'Red', 'Blue','Purple','White','Yellow'] + color = [[27,25,20], [50,20,160], [220,130,88], [185,100,115], [245,175,185],[90,150,170]] count = [0,0,0,0,0,0] vertexNames = [] @@ -168,7 +164,7 @@ def recursiveDFS(graph, vertexNames, seen, cur, parent): cv2.circle(cimg,(i[0],i[1]),i[2],(0,255,0),2) # draw the center of the circle cv2.circle(cimg,(i[0],i[1]),2,(0,0,255),3) - cv2.putText(cimg, colorNames[color_index], (i[0],i[1]), cv2.FONT_HERSHEY_SIMPLEX,0.6,(255,255,255),2) + cv2.putText(cimg, atomNames[color_index], (i[0],i[1]), cv2.FONT_HERSHEY_SIMPLEX,0.6,(255,255,255),2) #End for #Mark Connections @@ -193,9 +189,9 @@ def recursiveDFS(graph, vertexNames, seen, cur, parent): #End If cv2.imshow('Ball And Stick Tracker', cimg) - key = cv2.waitKey(200) + key = cv2.waitKey(50) if key==-1: continue - if chr(key)=='q': + if chr(key)=='q': quit=True break elif chr(key)=='s': @@ -205,26 +201,6 @@ def recursiveDFS(graph, vertexNames, seen, cur, parent): smile = DFS(graph, vertexNames) print smile print '' - elif chr(key)=='v': # visualization - print 'v was pressed' - print vertexNames - print graph - smile = DFS(graph, vertexNames) - print smile - print '' - if smile==None: - continue - molfile = query.MOL( smile ) - if not molfile == None: - name = query.iupac( smile ) - filename = name + '.mol' if not name==None else smile+'.mol' - print molfile - with open( filename, 'w') as infile: - infile.write( molfile ) - quit=True - - query.pymol_show( filename ) - break elif chr(key)=='x': cv2.imwrite("out"+str(COUNTER)+".jpg",image) COUNTER=COUNTER+1 @@ -239,4 +215,3 @@ def recursiveDFS(graph, vertexNames, seen, cur, parent): - diff --git a/leastWorkingModel.py b/leastWorkingModel.py index 957e649..f42d319 100644 --- a/leastWorkingModel.py +++ b/leastWorkingModel.py @@ -1,70 +1,233 @@ import cv2 import numpy as np import sys +import math +import cirpy +import Visualization.query as query def printHelpText(): print 'Welcome to our Least Working Program for IPRO 207 in Spring 2016' #End Function printHelpText() -cap = cv2.VideoCapture(0) -cv2.namedWindow('Ball And Stick Tracker',cv2.WINDOW_AUTOSIZE) +def distance3D(x,y): + return ((1.0*x[0]-y[0])**2+(1.0*x[1]-y[1])**2+(1.0*x[2]-y[2])**2)**(0.5) +#End Function distance() +def distance2D(x,y): + return ((1.0*x[0]-y[0])**2+(1.0*x[1]-y[1])**2)**(0.5) +#End Function distance() + +def averageColor(image,x,y,r): + total=[0,0,0] + count=0 + for dx in [-1*r, r]: + for dy in [-1*r, r]: + if x+dx <0: continue + if x+dx >= image.shape[0]: continue + if y+dy <0: continue + if y+dy >= image.shape[1]: continue + total[0] = total[0]+image[x+dx][y+dy][0] + total[1] = total[1]+image[x+dx][y+dy][1] + total[2] = total[2]+image[x+dx][y+dy][2] + count=count+1 + total[0]=total[0]/count + total[1]=total[1]/count + total[2]=total[2]/count + return total +#End Function distance() + +def nearestNeighbor(colors, pixel): + dist = -1 + index=-1 + i=0 + for c in colors: + d=distance3D(pixel, c) + if dist==-1 or d4*c1[2] and distance>4*c2[2]: return False + STEPS =25 + PERCENT_SKIP=0.3 + THRESHOLD=0.85 + p1 = c1*PERCENT_SKIP + c2*(1-PERCENT_SKIP) + p2 = c2*PERCENT_SKIP + c1*(1-PERCENT_SKIP) + direction = p2-p1 + count=0 + for i in range(STEPS): + step = direction*i/STEPS + test = p1 + step + if abs(distance3D(image[math.floor(test[1])][math.floor(test[0])], [190,150,155]))<45: + count = count+1 + return count>THRESHOLD +#End Function detectSingleBond() + +EDGE_REMOVAL_COUNTER=1 +def DFS(graph, vertexNames): + global EDGE_REMOVAL_COUNTER + if graph==None or graph==[]: return None + start = 0 + while len(graph[start])==0: + start=start+1 + if start==len(graph): return None + seen = [False]*len(graph) + EDGE_REMOVAL_COUNTER=0 + removeCycles(graph,vertexNames,seen,start,None) + ret='' + seen = [False]*len(graph) + return recursiveDFS(graph, vertexNames, seen, start, None) +#End Function DFS(graph, vertexNames) + + +def removeCycles(graph, vertexNames, seen, cur, parent): + print 'entering', cur + global EDGE_REMOVAL_COUNTER + seen[cur] = True + for j in graph[cur]: + if j==parent: + continue + if seen[j]: + graph[cur].remove(j) + vertexNames[cur] = vertexNames[cur]+numberString(EDGE_REMOVAL_COUNTER) + graph[j].remove(cur) + vertexNames[j] = vertexNames[j]+numberString(EDGE_REMOVAL_COUNTER) + EDGE_REMOVAL_COUNTER = EDGE_REMOVAL_COUNTER+1 + continue + removeCycles(graph, vertexNames, seen, j, cur) +#End Function removeCycles(graph, vertexNames, seen, cur) + +def numberString(i): + if i<10: return str(i) + return '%'+str(i) +#End Function numberString(i) + +def recursiveDFS(graph, vertexNames, seen, cur, parent): +#Assuming graph is acyclic + seen[cur] = True + ret = vertexNames[cur] + count=0 + if parent==None: count=-1 + for j in graph[cur]: + if j==parent: + continue + if seen[j]: + continue + count=count+1 + if not count==len(graph[cur])-1: + ret=ret+'(' + ret=ret+recursiveDFS(graph, vertexNames, seen, j, cur) + if not count==len(graph[cur])-1: + ret=ret+')' + return ret +#End Function recursiveDFS(graph, vertexNames, seen, cur) + +cap = cv2.VideoCapture(1) +cv2.namedWindow('Ball And Stick Tracker',cv2.CV_WINDOW_AUTOSIZE) + printHelpText() +COUNTER=50 quit=False while not quit: - key=-1 - if len(sys.argv)==2: - filename = sys.argv[1] - image = cv2.imread(filename) - cv2.imshow('Ball And Stick Tracker', image) - key = cv2.waitKey() - elif len(sys.argv)<2: - while key==-1: - retval,image = cap.read() - cv2.imshow('Ball And Stick Tracker', image) - key = cv2.waitKey(5) - #End If - - currentImage = cv2.medianBlur(image,5) + retval,image = cap.read() + cv2.imshow('Ball And Stick Tracker', image) + key = cv2.waitKey() while True: - if key>=256: break - if chr(key) == 'i': - break - elif chr(key) == 'c': - print 'here' - cimg = currentImage - img = cv2.cvtColor(currentImage,cv2.COLOR_BGR2GRAY) - print 'there' - circles = cv2.HoughCircles(img,cv2.cv.CV_HOUGH_GRADIENT,1,20, - param1=50,param2=30,minRadius=10,maxRadius=60) - print circles - if circles==None: break + vertexNames = None + graph = None + + retval,image = cap.read() + image = cv2.medianBlur(image,3) + cimg = image.copy() + img = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY) + circles = cv2.HoughCircles(img,cv2.cv.CV_HOUGH_GRADIENT,1,30, + param1=45,param2=25,minRadius=15,maxRadius=40) + if circles!=None: circles = np.uint16(np.around(circles)) - count=0 + atomNames = ['C', 'O', 'N','P','H','F'] + colorNames = ['Black', 'Red', 'Blue','Purple','White','Yellow'] + color = [[27,25,20], [50,20,160], [220,130,88], [185,100,115], [245,175,185],[90,150,170]] + count = [0,0,0,0,0,0] + + vertexNames = [] + graph = [] for i in circles[0,:]: - count=count+1 - if count>10:break + circleColor = averageColor(image, i[1], i[0], 1) + color_index = nearestNeighbor(color, circleColor) + count[color_index]=count[color_index]+1 + vertexNames.append(atomNames[color_index]) + # draw the outer circle cv2.circle(cimg,(i[0],i[1]),i[2],(0,255,0),2) # draw the center of the circle cv2.circle(cimg,(i[0],i[1]),2,(0,0,255),3) + cv2.putText(cimg, atomNames[color_index], (i[0],i[1]), cv2.FONT_HERSHEY_SIMPLEX,0.6,(255,255,255),2) #End for - currentImage = cimg - elif chr(key) == 'w': - cv2.imwrite("out.jpg",currentImage) - elif chr(key) == 'h': - printHelpText() - elif chr(key) == 'q': - quit = True - break - else: - print "Please only use supported chracters." + + #Mark Connections + for i in circles[0,:]: + adjList = [] + counter=0 + for j in circles[0,:]: + if (i==j).all(): + counter=counter+1 + continue + if detectSingleBond(image,i,j): + adjList.append(counter) + cv2.line(cimg,(i[0],i[1]),(j[0],j[1]),(255,0,0),3) + #End if + counter=counter+1 + #End for + graph.append(adjList) + #End for + #print vertexNames + #print count + #print graph + #End If + + cv2.imshow('Ball And Stick Tracker', cimg) + key = cv2.waitKey(50) + if key==-1: continue + if chr(key)=='q': + quit=True break - #End Ifs + elif chr(key)=='s': + print 's was pressed' + print vertexNames + print graph + smile = DFS(graph, vertexNames) + print smile + print '' + elif chr(key)=='v': # visualization + print 'v was pressed' + print vertexNames + print graph + smile = DFS(graph, vertexNames) + print smile + print '' + if smile==None: + continue + molfile = query.MOL( smile ) + if not molfile == None: + name = query.iupac( smile ) + filename = name + '.mol' if not name==None else smile+'.mol' + print molfile + with open( filename, 'w') as infile: + infile.write( molfile ) + quit=True - cv2.imshow('Ball And Stick Tracker', currentImage) - key = cv2.waitKey() + query.pymol_show( filename ) + break + elif chr(key)=='x': + cv2.imwrite("out"+str(COUNTER)+".jpg",image) + COUNTER=COUNTER+1 + elif chr(key)=='p': + break #End While #End While #End While @@ -74,4 +237,3 @@ def printHelpText(): - From 30faac501af691eef3f478cb43968e9607976321 Mon Sep 17 00:00:00 2001 From: Aczopek Date: Fri, 22 Apr 2016 07:37:28 -0500 Subject: [PATCH 13/17] Added files via upload --- Live-LeastWorkingModel.py | 35 +++++- leastWorkingModel.py | 252 +++++++------------------------------- 2 files changed, 74 insertions(+), 213 deletions(-) diff --git a/Live-LeastWorkingModel.py b/Live-LeastWorkingModel.py index 5b5b22b..c8eb93a 100644 --- a/Live-LeastWorkingModel.py +++ b/Live-LeastWorkingModel.py @@ -2,12 +2,14 @@ import numpy as np import sys import math +import cirpy +import Visualization.query as query def printHelpText(): print 'Welcome to our Least Working Program for IPRO 207 in Spring 2016' #End Function printHelpText() -def distance3D(x,y): +def distance3D(x,y): return ((1.0*x[0]-y[0])**2+(1.0*x[1]-y[1])**2+(1.0*x[2]-y[2])**2)**(0.5) #End Function distance() def distance2D(x,y): @@ -41,14 +43,14 @@ def nearestNeighbor(colors, pixel): d=distance3D(pixel, c) if dist==-1 or d4*c1[2] or distance>4*c2[2]: return False + if distance>4*c1[2] and distance>4*c2[2]: return False STEPS =25 PERCENT_SKIP=0.3 THRESHOLD=0.85 @@ -76,7 +78,7 @@ def DFS(graph, vertexNames): EDGE_REMOVAL_COUNTER=0 removeCycles(graph,vertexNames,seen,start,None) ret='' - seen = [False]*len(graph) + seen = [False]*len(graph) return recursiveDFS(graph, vertexNames, seen, start, None) #End Function DFS(graph, vertexNames) @@ -164,7 +166,7 @@ def recursiveDFS(graph, vertexNames, seen, cur, parent): cv2.circle(cimg,(i[0],i[1]),i[2],(0,255,0),2) # draw the center of the circle cv2.circle(cimg,(i[0],i[1]),2,(0,0,255),3) - cv2.putText(cimg, atomNames[color_index], (i[0],i[1]), cv2.FONT_HERSHEY_SIMPLEX,0.6,(255,255,255),2) + cv2.putText(cimg, atomNames[color_index], (i[0],i[1]), cv2.FONT_HERSHEY_SIMPLEX,0.6,(255,255,255),2) #End for #Mark Connections @@ -191,7 +193,7 @@ def recursiveDFS(graph, vertexNames, seen, cur, parent): cv2.imshow('Ball And Stick Tracker', cimg) key = cv2.waitKey(50) if key==-1: continue - if chr(key)=='q': + if chr(key)=='q': quit=True break elif chr(key)=='s': @@ -201,6 +203,26 @@ def recursiveDFS(graph, vertexNames, seen, cur, parent): smile = DFS(graph, vertexNames) print smile print '' + elif chr(key)=='v': # visualization + print 'v was pressed' + print vertexNames + print graph + smile = DFS(graph, vertexNames) + print smile + print '' + if smile==None: + continue + molfile = query.MOL( smile ) + if not molfile == None: + name = query.iupac( smile ) + filename = name + '.mol' if not name==None else smile+'.mol' + print molfile + with open( filename, 'w') as infile: + infile.write( molfile ) + quit=True + + query.pymol_show( filename ) + break elif chr(key)=='x': cv2.imwrite("out"+str(COUNTER)+".jpg",image) COUNTER=COUNTER+1 @@ -215,3 +237,4 @@ def recursiveDFS(graph, vertexNames, seen, cur, parent): + diff --git a/leastWorkingModel.py b/leastWorkingModel.py index f42d319..957e649 100644 --- a/leastWorkingModel.py +++ b/leastWorkingModel.py @@ -1,233 +1,70 @@ import cv2 import numpy as np import sys -import math -import cirpy -import Visualization.query as query def printHelpText(): print 'Welcome to our Least Working Program for IPRO 207 in Spring 2016' #End Function printHelpText() -def distance3D(x,y): - return ((1.0*x[0]-y[0])**2+(1.0*x[1]-y[1])**2+(1.0*x[2]-y[2])**2)**(0.5) -#End Function distance() -def distance2D(x,y): - return ((1.0*x[0]-y[0])**2+(1.0*x[1]-y[1])**2)**(0.5) -#End Function distance() - -def averageColor(image,x,y,r): - total=[0,0,0] - count=0 - for dx in [-1*r, r]: - for dy in [-1*r, r]: - if x+dx <0: continue - if x+dx >= image.shape[0]: continue - if y+dy <0: continue - if y+dy >= image.shape[1]: continue - total[0] = total[0]+image[x+dx][y+dy][0] - total[1] = total[1]+image[x+dx][y+dy][1] - total[2] = total[2]+image[x+dx][y+dy][2] - count=count+1 - total[0]=total[0]/count - total[1]=total[1]/count - total[2]=total[2]/count - return total -#End Function distance() - -def nearestNeighbor(colors, pixel): - dist = -1 - index=-1 - i=0 - for c in colors: - d=distance3D(pixel, c) - if dist==-1 or d4*c1[2] and distance>4*c2[2]: return False - STEPS =25 - PERCENT_SKIP=0.3 - THRESHOLD=0.85 - p1 = c1*PERCENT_SKIP + c2*(1-PERCENT_SKIP) - p2 = c2*PERCENT_SKIP + c1*(1-PERCENT_SKIP) - direction = p2-p1 - count=0 - for i in range(STEPS): - step = direction*i/STEPS - test = p1 + step - if abs(distance3D(image[math.floor(test[1])][math.floor(test[0])], [190,150,155]))<45: - count = count+1 - return count>THRESHOLD -#End Function detectSingleBond() - -EDGE_REMOVAL_COUNTER=1 -def DFS(graph, vertexNames): - global EDGE_REMOVAL_COUNTER - if graph==None or graph==[]: return None - start = 0 - while len(graph[start])==0: - start=start+1 - if start==len(graph): return None - seen = [False]*len(graph) - EDGE_REMOVAL_COUNTER=0 - removeCycles(graph,vertexNames,seen,start,None) - ret='' - seen = [False]*len(graph) - return recursiveDFS(graph, vertexNames, seen, start, None) -#End Function DFS(graph, vertexNames) - - -def removeCycles(graph, vertexNames, seen, cur, parent): - print 'entering', cur - global EDGE_REMOVAL_COUNTER - seen[cur] = True - for j in graph[cur]: - if j==parent: - continue - if seen[j]: - graph[cur].remove(j) - vertexNames[cur] = vertexNames[cur]+numberString(EDGE_REMOVAL_COUNTER) - graph[j].remove(cur) - vertexNames[j] = vertexNames[j]+numberString(EDGE_REMOVAL_COUNTER) - EDGE_REMOVAL_COUNTER = EDGE_REMOVAL_COUNTER+1 - continue - removeCycles(graph, vertexNames, seen, j, cur) -#End Function removeCycles(graph, vertexNames, seen, cur) - -def numberString(i): - if i<10: return str(i) - return '%'+str(i) -#End Function numberString(i) - -def recursiveDFS(graph, vertexNames, seen, cur, parent): -#Assuming graph is acyclic - seen[cur] = True - ret = vertexNames[cur] - count=0 - if parent==None: count=-1 - for j in graph[cur]: - if j==parent: - continue - if seen[j]: - continue - count=count+1 - if not count==len(graph[cur])-1: - ret=ret+'(' - ret=ret+recursiveDFS(graph, vertexNames, seen, j, cur) - if not count==len(graph[cur])-1: - ret=ret+')' - return ret -#End Function recursiveDFS(graph, vertexNames, seen, cur) - -cap = cv2.VideoCapture(1) -cv2.namedWindow('Ball And Stick Tracker',cv2.CV_WINDOW_AUTOSIZE) - +cap = cv2.VideoCapture(0) +cv2.namedWindow('Ball And Stick Tracker',cv2.WINDOW_AUTOSIZE) printHelpText() -COUNTER=50 quit=False while not quit: - retval,image = cap.read() - cv2.imshow('Ball And Stick Tracker', image) - key = cv2.waitKey() + key=-1 + if len(sys.argv)==2: + filename = sys.argv[1] + image = cv2.imread(filename) + cv2.imshow('Ball And Stick Tracker', image) + key = cv2.waitKey() + elif len(sys.argv)<2: + while key==-1: + retval,image = cap.read() + cv2.imshow('Ball And Stick Tracker', image) + key = cv2.waitKey(5) + #End If + + currentImage = cv2.medianBlur(image,5) while True: - vertexNames = None - graph = None - - retval,image = cap.read() - image = cv2.medianBlur(image,3) - cimg = image.copy() - img = cv2.cvtColor(image,cv2.COLOR_BGR2GRAY) - circles = cv2.HoughCircles(img,cv2.cv.CV_HOUGH_GRADIENT,1,30, - param1=45,param2=25,minRadius=15,maxRadius=40) - if circles!=None: + if key>=256: break + if chr(key) == 'i': + break + elif chr(key) == 'c': + print 'here' + cimg = currentImage + img = cv2.cvtColor(currentImage,cv2.COLOR_BGR2GRAY) + print 'there' + circles = cv2.HoughCircles(img,cv2.cv.CV_HOUGH_GRADIENT,1,20, + param1=50,param2=30,minRadius=10,maxRadius=60) + print circles + if circles==None: break circles = np.uint16(np.around(circles)) - atomNames = ['C', 'O', 'N','P','H','F'] - colorNames = ['Black', 'Red', 'Blue','Purple','White','Yellow'] - color = [[27,25,20], [50,20,160], [220,130,88], [185,100,115], [245,175,185],[90,150,170]] - count = [0,0,0,0,0,0] - - vertexNames = [] - graph = [] + count=0 for i in circles[0,:]: - circleColor = averageColor(image, i[1], i[0], 1) - color_index = nearestNeighbor(color, circleColor) - count[color_index]=count[color_index]+1 - vertexNames.append(atomNames[color_index]) - + count=count+1 + if count>10:break # draw the outer circle cv2.circle(cimg,(i[0],i[1]),i[2],(0,255,0),2) # draw the center of the circle cv2.circle(cimg,(i[0],i[1]),2,(0,0,255),3) - cv2.putText(cimg, atomNames[color_index], (i[0],i[1]), cv2.FONT_HERSHEY_SIMPLEX,0.6,(255,255,255),2) - #End for - - #Mark Connections - for i in circles[0,:]: - adjList = [] - counter=0 - for j in circles[0,:]: - if (i==j).all(): - counter=counter+1 - continue - if detectSingleBond(image,i,j): - adjList.append(counter) - cv2.line(cimg,(i[0],i[1]),(j[0],j[1]),(255,0,0),3) - #End if - counter=counter+1 - #End for - graph.append(adjList) #End for - #print vertexNames - #print count - #print graph - #End If - - cv2.imshow('Ball And Stick Tracker', cimg) - key = cv2.waitKey(50) - if key==-1: continue - if chr(key)=='q': - quit=True + currentImage = cimg + elif chr(key) == 'w': + cv2.imwrite("out.jpg",currentImage) + elif chr(key) == 'h': + printHelpText() + elif chr(key) == 'q': + quit = True break - elif chr(key)=='s': - print 's was pressed' - print vertexNames - print graph - smile = DFS(graph, vertexNames) - print smile - print '' - elif chr(key)=='v': # visualization - print 'v was pressed' - print vertexNames - print graph - smile = DFS(graph, vertexNames) - print smile - print '' - if smile==None: - continue - molfile = query.MOL( smile ) - if not molfile == None: - name = query.iupac( smile ) - filename = name + '.mol' if not name==None else smile+'.mol' - print molfile - with open( filename, 'w') as infile: - infile.write( molfile ) - quit=True - - query.pymol_show( filename ) - break - elif chr(key)=='x': - cv2.imwrite("out"+str(COUNTER)+".jpg",image) - COUNTER=COUNTER+1 - elif chr(key)=='p': + else: + print "Please only use supported chracters." break + #End Ifs + + cv2.imshow('Ball And Stick Tracker', currentImage) + key = cv2.waitKey() #End While #End While #End While @@ -237,3 +74,4 @@ def recursiveDFS(graph, vertexNames, seen, cur, parent): + From 7bac1ca465a001cb778a22eb1b79a91ef52aae1c Mon Sep 17 00:00:00 2001 From: Aczopek Date: Fri, 22 Apr 2016 07:37:59 -0500 Subject: [PATCH 14/17] Added files via upload --- django13api/__init__.pyc | Bin 110 -> 202 bytes django13api/settings.pyc | Bin 2949 -> 3026 bytes django13api/urls.py | 2 +- 3 files changed, 1 insertion(+), 1 deletion(-) diff --git a/django13api/__init__.pyc b/django13api/__init__.pyc index 909bde2fed2aa6421abcba987489336ed2661e85..3f308711784843da0aa29fb228d2eb22996d6688 100755 GIT binary patch delta 144 zcmc~h#mL6|nU`zY%86{|^~DSf3@%nN&XwuqnRzi8`MIev5t(@<`FZIvF8Rr&xv6<2 z#W9`%LHNip&150B`Yy6J>Sqcu^=->PcH_U8y}yUmst`Y SuUAl6!U43`CO3a#0v`a)S}+^{ delta 33 ocmX@bn8(KanU~8oc_N#+fH(sKgPwj$YDsExNoIbY{=}7v0F^}vkN^Mx diff --git a/django13api/settings.pyc b/django13api/settings.pyc index 196f5070ed1074938490435d375d92525dec3cf4..96aa22930f282d81bf388f32e31b54b782488781 100755 GIT binary patch delta 113 zcmZn_za-Aa{F#?)+L4WHcer9x7#J8_tYVxi)5|mSVlwh`Q)41B^Gfpb(qmlmlS^|` y^Gb?iJOhIKjSS3VoIQiUY~A33qRhN>BLhP-41P*hVqSW_p>bkCX3XSIT$2H;2`5AV delta 36 rcmca4-YU+<{F#@_wQeKZ9WDWJ1_lN_{gl*_)Z~)P{5<{1_S};J!nX?B diff --git a/django13api/urls.py b/django13api/urls.py index f9ccb26..f6c91b7 100755 --- a/django13api/urls.py +++ b/django13api/urls.py @@ -14,5 +14,5 @@ # Uncomment the next line to enable the admin: # url(r'^admin/', include(admin.site.urls)), - url(r'^detect/$', 'detection.detect.views.detect'), + url(r'^detect/$', 'detect.views.detect'), ) From 9d48f6fe63cb2526712cd482a164cb808c275aa0 Mon Sep 17 00:00:00 2001 From: Aczopek Date: Fri, 22 Apr 2016 07:38:33 -0500 Subject: [PATCH 15/17] Added files via upload --- quizAngular/app/views/template.html | 3 ++- quizAngular/app/views/template2.html | 3 ++- quizAngular/app/views/template3.html | 3 ++- quizAngular/app/views/template4.html | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/quizAngular/app/views/template.html b/quizAngular/app/views/template.html index 42f9ffe..1b8e943 100755 --- a/quizAngular/app/views/template.html +++ b/quizAngular/app/views/template.html @@ -56,7 +56,8 @@

      {{question}}

    - + + diff --git a/quizAngular/app/views/template2.html b/quizAngular/app/views/template2.html index 8452908..57e3eac 100755 --- a/quizAngular/app/views/template2.html +++ b/quizAngular/app/views/template2.html @@ -56,7 +56,8 @@

    {{question}}

    - + + diff --git a/quizAngular/app/views/template3.html b/quizAngular/app/views/template3.html index c18105c..f9b5f74 100755 --- a/quizAngular/app/views/template3.html +++ b/quizAngular/app/views/template3.html @@ -70,7 +70,8 @@

    {{question}}

    - + + diff --git a/quizAngular/app/views/template4.html b/quizAngular/app/views/template4.html index dcbff1b..8e38cbe 100755 --- a/quizAngular/app/views/template4.html +++ b/quizAngular/app/views/template4.html @@ -70,7 +70,8 @@

    {{question}}

    - + + From cc0d7f50753ac222f95220045bc34898e16cf894 Mon Sep 17 00:00:00 2001 From: Aczopek Date: Fri, 22 Apr 2016 07:39:06 -0500 Subject: [PATCH 16/17] Added files via upload --- quizAngular/dist/scripts/app.js | 33 + quizAngular/dist/scripts/controllers/about.js | 17 + quizAngular/dist/scripts/controllers/main.js | 897 ++++++++++++++++++ 3 files changed, 947 insertions(+) create mode 100644 quizAngular/dist/scripts/app.js create mode 100644 quizAngular/dist/scripts/controllers/about.js create mode 100644 quizAngular/dist/scripts/controllers/main.js diff --git a/quizAngular/dist/scripts/app.js b/quizAngular/dist/scripts/app.js new file mode 100644 index 0000000..9d4e96f --- /dev/null +++ b/quizAngular/dist/scripts/app.js @@ -0,0 +1,33 @@ +'use strict'; + +/** + * @ngdoc overview + * @name quizAngularApp + * @description + * # quizAngularApp + * + * Main module of the application. + */ +angular + .module('quizAngularApp', [ + 'ngAnimate', + 'ngCookies', + 'ngResource', + 'ngRoute', + 'ngSanitize', + 'ngTouch' + ]) + .config(function ($routeProvider) { + $routeProvider + .when('/', { + templateUrl: 'views/main.html', + controller: 'MainCtrl' + }) + .when('/about', { + templateUrl: 'views/about.html', + controller: 'AboutCtrl' + }) + .otherwise({ + redirectTo: '/' + }); + }); diff --git a/quizAngular/dist/scripts/controllers/about.js b/quizAngular/dist/scripts/controllers/about.js new file mode 100644 index 0000000..53fedba --- /dev/null +++ b/quizAngular/dist/scripts/controllers/about.js @@ -0,0 +1,17 @@ +'use strict'; + +/** + * @ngdoc function + * @name quizAngularApp.controller:AboutCtrl + * @description + * # AboutCtrl + * Controller of the quizAngularApp + */ +angular.module('quizAngularApp') + .controller('AboutCtrl', function ($scope) { + $scope.awesomeThings = [ + 'HTML5 Boilerplate', + 'AngularJS', + 'Karma' + ]; + }); diff --git a/quizAngular/dist/scripts/controllers/main.js b/quizAngular/dist/scripts/controllers/main.js new file mode 100644 index 0000000..99502ac --- /dev/null +++ b/quizAngular/dist/scripts/controllers/main.js @@ -0,0 +1,897 @@ +'use strict'; + +/** + * @ngdoc function + * @name quizAngularApp.controller:MainCtrl + * @description + * # MainCtrl + * Controller of the quizAngularApp + */ + +var SMILES; +function quiz(quizFactory) { + return { + restrict: 'AE', + scope: {}, + templateUrl: 'views/template.html', + link: function(scope, elem, attrs) { + scope.start = function() { + scope.id = 0; + scope.quizOver = false; + scope.inProgress = true; + scope.getQuestion(); + }; + + scope.reset = function() { + scope.inProgress = false; + scope.score = 0; + }; + + scope.getQuestion = function() { + var q = quizFactory.getQuestion(scope.id); + var size = quizFactory.setSize; + if(q) { + scope.type = q.type; + scope.question = q.question; + scope.options = q.options; + scope.answer = q.answer; + scope.imgs = q.imgs; + scope.answerMode = true; + $('textarea').val(''); + $('input:radio:checked').prop('checked', false); + $('.progress-bar').css('width', scope.id/size*100+'%'); + } else { + scope.quizOver = true; + } + }; + + scope.checkAnswer = function() { + switch( scope.type ) { + case '0': + if(!$('input[name=answer]:checked').length) { + return; + } + var ans = $('input[name=answer]:checked').val(); + + if(ans === scope.options[scope.answer]) { + scope.score++; + scope.correctAns = true; + } else { + scope.correctAns = false; + } + break; + case '1': + var ans = $('textarea').val(); + if (!ans.length) {return;} + if (ans === scope.answer) { + scope.score++; + scope.correctAns = true; + } else { + scope.correctAns = false; + } + break; + case '3': + console.log('SMILES is'+SMILES); + if(!SMILES) {return;} + if(scope.answer === SMILES) { + scope.score++; + scope.correctAns = true; + } else { + scope.correctAns = false; + } + break; + } + + + scope.answerMode = false; + }; + + scope.nextQuestion = function() { + scope.id++; + scope.getQuestion(); + }; + + scope.reset(); + } + }; +} + +function quizFactory() { + var questions = [ + { + type: '0', + question: 'Select a correct IUPAC name for the structure below.', + options: ['2-iodo-4-ethyl-4-methylpentane', '3,3-dimethyl-5-iodohexane', '2-iodo-4,4-dimethylhexane', '2-ethyl-2-methyl-4-iodopentane'], + imgs:'1.PNG', + answer: 2 + }, + { + type: '0', + question: 'Select a correct IUPAC name for the structure below.', + options: ['1-ethyl-1-isopropylhexane', '2-methyl-3-ethyloctane', '3-ethyl-2-methyloctane', '2-methyl-3-pentylpentane'], + imgs:'2.PNG', + answer: 2 + }, + { + type: '0', + question: 'Select a correct IUPAC name for the structure below.', + options: ['2-methyl-3-ethylheptane', '3-butyl-2-methylpentane', '3-ethyl-2-methylheptane', '5-isopropylheptane'], + imgs:'3.PNG', + answer: 2 + }, + { + type: '1', + question: 'Name the following compound according to the IUPAC system', + options: [], + imgs:'4.PNG', + answer: '2-ethyl-1,1-dimethylcyclopropane' + }, + { + type: '1', + question: 'Name the following compound according to the IUPAC system', + options: [], + imgs: '6.PNG', + answer: '3-ethyl-2-methylpentane' + }, + { + type: '3', + question: 'Build ethanol.', + options: [], + imgs:'', + answer: 'CCO' + }, + { + type: '3', + question: 'Build 5-ethyl-2,3,4-trimethylheptane.', + options: [], + imgs:'', + answer: 'CCC(CC)C(C)C(C)C(C)C' + }, + { + type: '3', + question: 'Build 2-chlorobutane.', + options: [], + imgs:'', + answer: 'CCC(C)Cl' + }, + { + type: '3', + question: 'Build 2-ethylthiobutane.', + options: [], + imgs:'', + answer: 'CCSC(C)CC' + }, + { + type: '3', + question: 'Build 1-methoxybutane.', + options: [], + imgs:'', + answer: 'CCCCOC' + } + ]; + + return { + setSize: questions.length, + getQuestion: function(id) { + if(id < questions.length) { + return questions[id]; + } else { + return false; + } + } + }; +} +function quiz2(quizFactory2) { + return { + restrict: 'AE', + scope: {}, + templateUrl: 'views/template2.html', + link: function(scope, elem, attrs) { + scope.start = function() { + scope.id = 0; + scope.quizOver = false; + scope.inProgress = true; + scope.getQuestion(); + }; + + scope.reset = function() { + scope.inProgress = false; + scope.score = 0; + }; + + scope.getQuestion = function() { + var q = quizFactory2.getQuestion(scope.id); + var size = quizFactory2.setSize; + if(q) { + scope.type = q.type; + scope.question = q.question; + scope.options = q.options; + scope.answer = q.answer; + scope.imgs = q.imgs; + scope.answerMode = true; + $('textarea').val(''); + $('input:radio:checked').prop('checked', false); + $('.progress-bar').css('width', scope.id/size*100+'%'); + } else { + scope.quizOver = true; + } + }; + + scope.checkAnswer = function() { + switch( scope.type ) { + case '0': + if(!$('input[name=answer]:checked').length) { + return; + } + var ans = $('input[name=answer]:checked').val(); + if(ans === scope.options[scope.answer]) { + scope.score++; + scope.correctAns = true; + } else { + scope.correctAns = false; + } + break; + case '1': + var ans = $('textarea').val(); + if (!ans.length) {return;} + if (ans === scope.answer) { + scope.score++; + scope.correctAns = true; + } else { + scope.correctAns = false; + } + break; + case '3': + console.log('SMILES is'+SMILES); + if(!SMILES) {return;} + if(scope.answer === SMILES) { + scope.score++; + scope.correctAns = true; + } else { + scope.correctAns = false; + } + break; + } + + + scope.answerMode = false; + }; + + scope.nextQuestion = function() { + scope.id++; + scope.getQuestion(); + }; + + scope.reset(); + } + }; +} + +function quizFactory2() { + var questions = [ + { + type: '3', + question: 'Build water.', + options: [], + imgs:'', + answer: 'HOH' + }, + { + type: '0', + question: 'Select a correct configuration of the following molecule?', + options: ['S', 'R'], + imgs:'21-1.PNG', + answer: 0 + }, + { + type: '0', + question: 'Select a correct configuration of the following molecule?', + options: ['S', 'R'], + imgs:'21-2.PNG', + answer: 1 + }, + { + type: '0', + question: 'Select a correct configuration of the following molecule?', + options: ['S', 'R'], + imgs:'21-3.PNG', + answer: 0 + }, + { + type: '0', + question: 'Select a correct configuration of the following molecule?', + options: ['S', 'R'], + imgs:'21-4.PNG', + answer: 1 + }, + { + type: '0', + question: 'Select a correct configuration of the following molecule?', + options: ['S', 'R'], + imgs:'21-5.PNG', + answer: 0 + }, + + { + type: '0', + question: 'Select a correct configuration of the following molecule?', + options: ['S', 'R'], + imgs:'21-6.PNG', + answer: 1 + }, + { + type: '0', + question: 'Is the molecule chiral or achiral', + options: ['chiral', 'achiral'], + imgs:'22-1.PNG', + answer: 1 + }, + { + type: '0', + question: 'Is the molecule chiral or achiral', + options: ['chiral', 'achiral'], + imgs:'22-2.PNG', + answer: 1 + }, + { + type: '0', + question: 'Is the molecule chiral or achiral', + options: ['chiral', 'achiral'], + imgs:'22-3.PNG', + answer: 0 + }, + { + type: '0', + question: 'Is the molecule chiral or achiral', + options: ['chiral', 'achiral'], + imgs:'22-4.PNG', + answer: 1 + }, + { + type: '1', + question: 'What is the configuration of the following molecule?', + options: [], + imgs: '20-1.PNG', + answer: 'R' + }, + { + type: '1', + question: 'What is the configuration of the following molecule?', + options: [], + imgs: '20-2.PNG', + answer: 'R' + }, + { + type: '1', + question: 'What is the configuration of the following molecule?', + options: [], + imgs: '20-3.PNG', + answer: 'R' + }, + { + type: '1', + question: 'What is the configuration of the following molecule?', + options: [], + imgs: '20-4.PNG', + answer: 'R' + }, + { + type: '1', + question: 'What is the configuration of the following molecule?', + options: [], + imgs: '20-5.PNG', + answer: 'R' + }, + { + type: '1', + question: 'What is the configuration of the following molecule?', + options: [], + imgs: '20-6.PNG', + answer: 'S' + }, + { + type: '1', + question: 'What is the configuration of the following molecule?', + options: [], + imgs: '20-7.PNG', + answer: 'R' + }, + { + type: '1', + question: 'What is the configuration of the following molecule?', + options: [], + imgs: '20-8.PNG', + answer: 'R' + }, + { + type: '1', + question: 'What is the configuration of the following molecule?', + options: [], + imgs: '20-9.PNG', + answer: 'R' + }, + { + type: '1', + question: 'What is the configuration of the following molecule?', + options: [], + imgs: '20-10.PNG', + answer: 'R' + }, + { + type: '1', + question: 'What is the configuration of the following molecule?', + options: [], + imgs: '20-11.PNG', + answer: 'R' + } + ]; + + return { + setSize: questions.length, + getQuestion: function(id) { + if(id < questions.length) { + return questions[id]; + } else { + return false; + } + } + }; +} + +function quiz3(quizFactory3) { + return { + restrict: 'AE', + scope: {}, + templateUrl: 'views/template3.html', + link: function(scope, elem, attrs) { + scope.start = function() { + scope.id = 0; + scope.quizOver = false; + scope.inProgress = true; + scope.getQuestion(); + }; + + scope.reset = function() { + scope.inProgress = false; + scope.score = 0; + }; + + scope.getQuestion = function() { + var q = quizFactory3.getQuestion(scope.id); + var size = quizFactory3.setSize; + if(q) { + scope.type = q.type; + scope.question = q.question; + scope.options = q.options; + scope.answer = q.answer; + scope.imgs = q.imgs; + scope.answerMode = true; + $('textarea').val(''); + $('input:radio:checked').prop('checked', false); + $('.progress-bar').css('width', scope.id/size*100+'%'); + } else { + scope.quizOver = true; + } + }; + + scope.checkAnswer = function() { + switch( scope.type ) { + case '0': + if(!$('input[name=answer]:checked').length) { + return; + } + var ans = $('input[name=answer]:checked').val(); + + if(ans === scope.options[scope.answer]) { + scope.score++; + scope.correctAns = true; + } else { + scope.correctAns = false; + } + break; + case '1': + var ans = $('textarea').val(); + if (!ans.length) {return;} + if (ans === scope.answer) { + scope.score++; + scope.correctAns = true; + } else { + scope.correctAns = false; + } + break; + case '3': + console.log('SMILES is'+SMILES); + if(!SMILES) {return;} + if(scope.answer === SMILES) { + scope.score++; + scope.correctAns = true; + } else { + scope.correctAns = false; + } + break; + } + + + scope.answerMode = false; + }; + + scope.nextQuestion = function() { + scope.id++; + scope.getQuestion(); + }; + + scope.reset(); + } + }; +} + +function quizFactory3() { + var questions = [ + { + type: '0', + question: "Which is the best reaction sequence to use if one wants to accomplish an alcohol synthesis shown? ", + options: ["NaOH/H2O", " KMnO4/H2O", " i) Hg(OAc)2/H2O; ii) NaBH4", " i) BH3; ii)H2O2/HO"], + imgs:'10.PNG', + answer: 2 + }, + { + type: '3', + question: "Build the result of the reaction sequence shown?", + options: [], + imgs:'25-1.PNG', + answer: 'CH3CH2CH=CH2' + }, + { + type: '3', + question: "Build the result of the reaction sequence shown?", + options: [], + imgs:'25-2.PNG', + answer: 'CH3CH2CH2CH2PCH3' + }, + { + type: '3', + question: "Build the result of the reaction sequence shown?", + options: [], + imgs:'25-3.PNG', + answer: 'SCH2CH3' + }, + { + type: '3', + question: "Build the result of the reaction sequence shown?", + options: [], + imgs:'25-4.PNG', + answer: 'CCC(CC)C(C)C(C)C(C)C' + }, + { + type: '3', + question: "Build the result of the reaction sequence shown?", + options: [], + imgs:'25-5.PNG', + answer: 'CCC(CC)C(C)C(C)C(C)C' + }, + { + type: '3', + question: "Build the result of the reaction sequence shown?", + options: [], + imgs:'25-6.PNG', + answer: 'CCC(CC)C(C)C(C)C(C)C' + }, + { + type: '3', + question: "Build the result of the reaction sequence shown?", + options: [], + imgs:'25-7.PNG', + answer: 'CCC(CC)C(C)C(C)C(C)C' + }, + { + type: '0', + question: "Which is the best reaction sequence to use if one wants to accomplish the synthesis shown?", + options: ["KMnO4/H2O", "Hg(OAc)2/H2O; ii) NaBH4", " i) KOC(CH3)3; ii) (CH3)3COH", " i) BH3; ii)H2O2/HO"], + imgs:'12.PNG', + answer: 2 + } + ]; + + return { + setSize: questions.length, + getQuestion: function(id) { + if(id < questions.length) { + return questions[id]; + } else { + return false; + } + } + }; +} + +function quiz4(quizFactory4) { + return { + restrict: 'AE', + scope: {}, + templateUrl: 'views/template4.html', + link: function(scope, elem, attrs) { + scope.start = function() { + scope.id = 0; + scope.quizOver = false; + scope.inProgress = true; + scope.getQuestion(); + }; + + scope.reset = function() { + scope.inProgress = false; + scope.score = 0; + }; + + scope.getQuestion = function() { + var q = quizFactory4.getQuestion(scope.id); + var size = quizFactory4.setSize; + if(q) { + scope.type = q.type; + scope.question = q.question; + scope.options = q.options; + scope.answer = q.answer; + scope.imgs = q.imgs; + scope.answerMode = true; + $('textarea').val(''); + $('input:radio:checked').prop('checked', false); + $('.progress-bar').css('width', scope.id/size*100+'%'); + } else { + scope.quizOver = true; + } + }; + + scope.checkAnswer = function() { + switch( scope.type ) { + case '0': + if(!$('input[name=answer]:checked').length) { + return; + } + var ans = $('input[name=answer]:checked').val(); + + if(ans === scope.options[scope.answer]) { + scope.score++; + scope.correctAns = true; + } else { + scope.correctAns = false; + } + break; + case '1': + var ans = $('textarea').val(); + if (!ans.length) {return;} + if (ans === scope.answer) { + scope.score++; + scope.correctAns = true; + } else { + scope.correctAns = false; + } + break; + case '3': + console.log('SMILES is'+SMILES); + if(!SMILES) {return;} + if(scope.answer === SMILES) { + scope.score++; + scope.correctAns = true; + } else { + scope.correctAns = false; + } + break; + } + + + scope.answerMode = false; + }; + + scope.nextQuestion = function() { + scope.id++; + scope.getQuestion(); + }; + + scope.reset(); + } + }; +} + +function quizFactory4() { + var questions = [ + { + type: '3', + question: "Build the molecule that does NOT contain carbon atoms: A) Water B) Propane C) Carbonite ", + options: [], + imgs:'', + answer: '', + hint:"hint", + }, + { + type: '3', + question: "Build a Dihydrogen Monoxide molecule.", + options: [], + imgs:'', + answer: 'DHMO', + hint:"hint", + }, + { + type: '3', + question: "A Cyclohexane molecule consists of 6 carbons that form a hexagon shape. Build a Cyclopentane molecule.", + options: [], + imgs:'', + answer: 'C1CCCCC1', + hint:"hint", + }, + { + type: '3', + question: "Build the molecule that is an alcohol: A) Ethane B)Ethene C)Ethanol (pictures shown?)", + options: [], + imgs:'', + answer: '', + hint:"hint", + }, + { + type: '3', + question: "Build the molecule that is an alkane: A) Ethane B)Ethene C)Ethanol (pictures shown?)", + options: [], + imgs:'', + answer: '', + hint:"hint", + }, + { + type: '3', + question: "Build a Carbon Dioxide molecule (Assume single bond piece represents double bond)", + options: [], + imgs:'', + answer: 'CO2', + hint:"hint", + }, + { + type: '3', + question: "Build a Hydrogen Peroxide molecule.", + options: [], + imgs:'', + answer: 'H2O2', + hint:"hint", + }, + { + type: '3', + question: "Build an Octane molecule.", + options: [], + imgs:'', + answer: 'C8H18', + hint:"hint", + }, + { + type: '3', + question: "Build a Hydrogen Molecule.", + options: [], + imgs:'', + answer: 'H', + hint:"hint", + }, + { + type: '3', + question: "2 molecules of H2O were formed by combining 2 molecules of H2 and 1 molecule of X. Build this molecule.", + options: [], + imgs:'', + answer: 'CCC(CC)C(C)C(C)C(C)C', + hint:"hint", + } + ]; + + return { + setSize: questions.length, + getQuestion: function(id) { + if(id < questions.length) { + return questions[id]; + } else { + return false; + } + } + }; +} + + +angular.module('quizAngularApp') + .directive('quiz', quiz) + .directive('quiz2', quiz2) + .directive('quiz3', quiz3) + .directive('quiz4', quiz4) + .factory('quizFactory', quizFactory) + .factory('quizFactory2', quizFactory2) + .factory('quizFactory3', quizFactory3) + .factory('quizFactory4', quizFactory4) + .controller('MainCtrl', function ($scope) { + $scope.awesomeThings = [ + 'HTML5 Boilerplate', + 'AngularJS', + 'Karma' + ]; + }); + + +$('#start').on('click', + function(){ + var mediaOptions = { audio: false, video: true }; + + if (!navigator.getUserMedia) { + navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia; + } + + if (!navigator.getUserMedia){ + return alert('getUserMedia not supported in this browser.'); + } + + function success(stream){ + var video = document.querySelector('#player'); + video.src = window.URL.createObjectURL(stream); + } + + navigator.getUserMedia(mediaOptions, success, function(e) { + console.log(e); + }); + + + }); + + + +var start = function() { + //Compatibility + navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia; + + var canvas = document.getElementById('canvas'), + context = canvas.getContext('2d'), + video = document.getElementById('video'), + btnRecord = document.getElementById('btnRecord'), + btnPhoto = document.getElementById('btnPhoto'), + btnStop = document.getElementById('btnStop'), + videoObj = { + video: true, + audio: false + }; + $('#btnStart').prop('disabled', true); + + btnRecord.addEventListener('click', function() { + var localMediaStream; + + if (navigator.getUserMedia) { + navigator.getUserMedia(videoObj, function(stream) { + video.src = (navigator.webkitGetUserMedia) ? window.URL.createObjectURL(stream) : stream; + localMediaStream = stream; + + }, function(error) { + console.error('Video capture error: ', error.code); + }); + + btnStop.addEventListener('click', function() { + localMediaStream.getVideoTracks()[0].stop(); + }); + + btnPhoto.addEventListener('click', function() { + context.drawImage(video, 0, 0, 640, 480); + var data = canvas.toDataURL('image/PNG', 1.0), array = []; + data = atob(data.split(',')[1]); + for (var i=0; i Date: Fri, 22 Apr 2016 07:39:30 -0500 Subject: [PATCH 17/17] Added files via upload --- quizAngular/views/about.html | 1 + quizAngular/views/template.html | 89 +++++++++++++++++++++++++++ quizAngular/views/template2.html | 88 ++++++++++++++++++++++++++ quizAngular/views/template3.html | 102 +++++++++++++++++++++++++++++++ quizAngular/views/template4.html | 102 +++++++++++++++++++++++++++++++ 5 files changed, 382 insertions(+) create mode 100644 quizAngular/views/about.html create mode 100644 quizAngular/views/template.html create mode 100644 quizAngular/views/template2.html create mode 100644 quizAngular/views/template3.html create mode 100644 quizAngular/views/template4.html diff --git a/quizAngular/views/about.html b/quizAngular/views/about.html new file mode 100644 index 0000000..d21bf89 --- /dev/null +++ b/quizAngular/views/about.html @@ -0,0 +1 @@ +

    This is the about view.

    diff --git a/quizAngular/views/template.html b/quizAngular/views/template.html new file mode 100644 index 0000000..1b8e943 --- /dev/null +++ b/quizAngular/views/template.html @@ -0,0 +1,89 @@ +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    {{question}}

    +
    +
      +
    • + +
    • +
    +
    + +
    + +
    +
    + +
    +
    +
    +
    Instructions
    +
      +
    1. Start playing by clicking . The button will be disabled after being activated only once.
    2. +
    3. Start the web camera stream by clicking .
    4. +
    5. Capture a picture and submit the picture to server that can detect the model you built by clicking .
    6. +
    7. In case that you want to stop the web cam stream, click .
    8. +
    9. Submit the result as usual once you are confident with the result.
    10. +
    +
    +
    +
    +
    + +
    +
    + +
    +
    + +
    +
    + +
    + + + + +
    + + +
    +
    + +
    + +
    + + Correct! + Incorrect :( +
    +
    +
    + +
    +

    Quiz is over. Score: {{score}}

    + +
    + +
    + +
    +

    Nomenclature

    +
    +

    This series of questions will help you review nomenclature of organic molecules. Apart from traditional exercise questions, you will be building several molecules based on their name using the modelling kit.

    +
    +
    + Begin! +
    + diff --git a/quizAngular/views/template2.html b/quizAngular/views/template2.html new file mode 100644 index 0000000..57e3eac --- /dev/null +++ b/quizAngular/views/template2.html @@ -0,0 +1,88 @@ +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    {{question}}

    +

    {{hint}}

    +
    +
      +
    • + +
    • +
    +
    + +
    + +
    +
    + +
    +
    +
    +
    Instructions
    +
      +
    1. Start playing by clicking . The button will be disabled after being activated only once.
    2. +
    3. Start the web camera stream by clicking .
    4. +
    5. Capture a picture and submit the picture to server that can detect the model you built by clicking .
    6. +
    7. In case that you want to stop the web cam stream, click .
    8. +
    9. Submit the result as usual once you are confident with the result.
    10. +
    +
    +
    +
    + +
    +
    + +
    +
    + +
    +
    + +
    + + + + +
    + + +
    +
    + +
    + +
    + + Correct! + Incorrect :( +
    +
    +
    + +
    +

    Quiz is over. Score: {{score}}

    + +
    + +
    + +
    +

    Stereochemistry

    +
    +

    Stereochemistry, a subdiscipline of chemistry, involves the study of the relative spatial arrangement of atoms that form the structure of molecules and their manipulation. An important branch of stereochemistry is the study of chiral molecules.

    +
    +
    + Begin! +
    \ No newline at end of file diff --git a/quizAngular/views/template3.html b/quizAngular/views/template3.html new file mode 100644 index 0000000..f9b5f74 --- /dev/null +++ b/quizAngular/views/template3.html @@ -0,0 +1,102 @@ + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    {{question}}

    +

    {{hint}}

    +
    +
      +
    • + +
    • +
    +
    + +
    + +
    +
    + +
    +
    + +
    +
    Instructions
    +
      +
    1. Start playing by clicking . The button will be disabled after being activated only once.
    2. +
    3. Start the web camera stream by clicking .
    4. +
    5. Capture a picture and submit the picture to server that can detect the model you built by clicking .
    6. +
    7. In case that you want to stop the web cam stream, click .
    8. +
    9. Submit the result as usual once you are confident with the result.
    10. +
    +
    +
    +
    + +
    +
    + +
    +
    + +
    +
    + +
    + + + + +
    + + +
    +
    + +
    + +
    + + Correct! + Incorrect :( +
    +
    +
    + +
    +

    Quiz is over. Score: {{score}}

    + +
    + +
    + +
    +

    Reactions

    +
    +

    A chemical reaction is when a substance (or a few substances) change into another substance. Chemical reactions are chemical transformations. If you take a chemistry class, you'll definitely learn about chemical reactions: when one or more substances change into something else. Get tested on your knowledge of reactions.

    +
    +
    + Begin! +
    \ No newline at end of file diff --git a/quizAngular/views/template4.html b/quizAngular/views/template4.html new file mode 100644 index 0000000..8e38cbe --- /dev/null +++ b/quizAngular/views/template4.html @@ -0,0 +1,102 @@ + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    +

    {{question}}

    +

    {{hint}}

    +
    +
      +
    • + +
    • +
    +
    + +
    + +
    +
    + +
    +
    +
    +
    Instructions
    +
      +
    1. Start playing by clicking . The button will be disabled after being activated only once.
    2. +
    3. Start the web camera stream by clicking .
    4. +
    5. Capture a picture and submit the picture to server that can detect the model you built by clicking .
    6. +
    7. In case that you want to stop the web cam stream, click .
    8. +
    9. Submit the result as usual once you are confident with the result.
    10. +
    +
    +
    +
    + +
    +
    + +
    +
    + +
    +
    + + +
    + + + + +
    + + +
    +
    + +
    + +
    + + Correct! + Incorrect :( +
    +
    +
    + +
    +

    Quiz is over. Score: {{score}}

    + +
    + +
    + +
    +

    Easy Quiz

    +
    +

    A collection of easy quiz to get started with!

    +
    +
    + Begin! +
    \ No newline at end of file