6
6
import sys
7
7
import os
8
8
import time
9
- import cv2 # install cv3, python3: http://seeb0h.github.io/howto/howto- install-homebrew-python-opencv-osx-el-capitan/
9
+ import cv2 # install cv3, python3: brew install opencv3 --with-contrib --with-python3 --without-python
10
10
# add to profile: export PYTHONPATH=$PYTHONPATH:/usr/local/Cellar/opencv3/3.2.0/lib/python3.6/site-packages/
11
11
import numpy as np
12
12
from scipy .spatial import distance
@@ -128,10 +128,12 @@ def computeOutVar(path):
128
128
pframe = cv2 .resize (frame , dsize = (args .size , args .size ))
129
129
130
130
# prepare and normalize frame for processing:
131
- pframe = np .swapaxes (pframe , 0 , 2 )
132
- pframe = np .expand_dims (pframe , axis = 0 )
131
+ # pframe = np.swapaxes(pframe, 0, 2)
132
+ # pframe = np.expand_dims(pframe, axis=0)
133
+ # print(pframe)
133
134
pframe = transformsImage (pframe )
134
135
pframe = torch .autograd .Variable (pframe ) # turn Tensor to variable required for pytorch processing
136
+ pframe = pframe .unsqueeze (0 )
135
137
136
138
# process via CNN model:
137
139
output = model (pframe )
@@ -142,7 +144,7 @@ def computeOutVar(path):
142
144
output = output .data .numpy ()[0 ] # get data from pytorch Variable, [0] = get vector from array
143
145
144
146
# detect key presses:
145
- keyPressed = cv2 .waitKey (33 )
147
+ keyPressed = cv2 .waitKey (1 )
146
148
if keyPressed == ord ('1' ):
147
149
protos [:,0 ] = output
148
150
print ("Learned object 1" )
0 commit comments