cv2

Reading image file (file storage object) using CV2

☆樱花仙子☆ 提交于 2019-12-03 14:45:47
I am sending an image by curl to flask server, i am using this curl command curl -F "file=@image.jpg" http://localhost:8000/home and I am trying to read the file using CV2 on the server side. On the server side I handle the image by this code @app.route('/home', methods=['POST']) def home(): data =request.files['file'] img = cv2.imread(data) fact_resp= model.predict(img) return jsonify(fact_resp) I am getting this error- img = cv2.imread(data) TypeError: expected string or Unicode object, FileStorage found How do I read the file using CV2 on the server side? Thanks! I had similar issues while

python import error in opencv

允我心安 提交于 2019-12-02 16:08:01
问题 I am getting this error when trying to import opencv: >>> import cv2 RuntimeError: module compiled against API version 0xa but this version of numpy is 0x7 Traceback (most recent call last): File "<pyshell#2>", line 1, in <module> import cv2 ImportError: numpy.core.multiarray failed to import 回答1: What version of Numpy are you running? You appear to only be running 1.7 Upgrade to the latest (1.14 as of writing) and try again. 来源: https://stackoverflow.com/questions/48684127/python-import

OpenCV, How to pass parameters into cv2.TrackerMedianFlow_create function?

冷暖自知 提交于 2019-12-02 11:32:34
问题 I'm trying to create MEDIANFLOW tracker with OpenCV3.3 using opencv-python with Python3.6. I need to pass some arguments into the constructor according to this page of OpenCV docs. The problem is I don't know how to pass available arguments into this function correctly? I wasn't able to find any information about it. What I do (and it works): tracker = cv2.TrackerMedianFlow_create() What I want to do: tracker = cv2.TrackerMedianFlow_create(maxLevel=3) But it doesn't work and gives me an error

python import error in opencv

冷暖自知 提交于 2019-12-02 10:12:28
I am getting this error when trying to import opencv: >>> import cv2 RuntimeError: module compiled against API version 0xa but this version of numpy is 0x7 Traceback (most recent call last): File "<pyshell#2>", line 1, in <module> import cv2 ImportError: numpy.core.multiarray failed to import What version of Numpy are you running? You appear to only be running 1.7 Upgrade to the latest (1.14 as of writing) and try again. 来源: https://stackoverflow.com/questions/48684127/python-import-error-in-opencv

CV2: “[ WARN:0] terminating async callback” when attempting to take a picture

老子叫甜甜 提交于 2019-12-01 21:40:14
I am trying to take a picture from the defualt carmera with python, to do this I am using openCV ( import cv2 from python shell). However, when I attempt to disable the camera it closes but with the error [ WARN:0] terminating async callback . This is code I am trying to run: import cv2 camera_port = 0 camera = cv2.VideoCapture(camera_port) return_value, image = camera.read() cv2.imwrite("image.png", image) camera.release() # Error is here The code outputs the desired result- it takes a saves an image but I do not understand why the error message occures or how to remove it It's probably

CV2: “[ WARN:0] terminating async callback” when attempting to take a picture

半城伤御伤魂 提交于 2019-12-01 20:23:38
问题 I am trying to take a picture from the defualt carmera with python, to do this I am using openCV ( import cv2 from python shell). However, when I attempt to disable the camera it closes but with the error [ WARN:0] terminating async callback . This is code I am trying to run: import cv2 camera_port = 0 camera = cv2.VideoCapture(camera_port) return_value, image = camera.read() cv2.imwrite("image.png", image) camera.release() # Error is here The code outputs the desired result- it takes a saves

Getting error: Cannot reshape array of size 122304 into shape (52,28,28)

自闭症网瘾萝莉.ら 提交于 2019-12-01 16:52:32
问题 I'm trying to reshape a numpy array as: data3 = data3.reshape((data3.shape[0], 28, 28)) where data3 is: [[54 68 66 ..., 83 72 58] [63 63 63 ..., 51 51 51] [41 45 80 ..., 44 46 81] ..., [58 60 61 ..., 75 75 81] [56 58 59 ..., 72 75 80] [ 4 4 4 ..., 8 8 8]] data3.shape is (52, 2352 ) But I keep getting the following error: ValueError: cannot reshape array of size 122304 into shape (52,28,28) Exception TypeError: TypeError("'NoneType' object is not callable",) in <function _remove at 0x10b6477d0

How to get the duration of video using cv2

有些话、适合烂在心里 提交于 2019-12-01 14:24:45
问题 I can only get the number of frames CAP_PROP_FRAME_COUNT using CV2. However, I cannot find the parameter to get the duration of the video using cv2. How to do that? Thank you very much. 回答1: cv2 is not designed to explore video metadata, so VideoCapture doesn't have API to retrieve it directly. You can instead "measure" the length of the stream: seek to the end, then get the timestamp: >>> v=cv2.VideoCapture('sample.avi') >>> v.set(cv2.CAP_PROP_POS_AVI_RATIO,1) True >>> v.get(cv2.CAP_PROP_POS

Pickle exception for cv2.Boost when using multiprocessing

青春壹個敷衍的年華 提交于 2019-12-01 13:17:15
I'm working on project named "Faciel Actions Units Detection" I'm using python2.7 and opencv 2.4 The error: pickle.PicklingError: Can't pickle <type 'cv2.Boost'>: it's not the same object as cv2.Boost A partial traceback, transcribed from a screenshot : Loading classifier for action unit 27 Traceback (most recent call last): File "C:\Python27\audetect-master\audetect-interactive.py", line 59, in <module> main() File "C:\Python27\audetect-master\audetect-interactive.py", line 18, in main active_aus = detector.detect() File "C:\Python27\audetect-master\detect.py", line 67, in detect initial

Pickle exception for cv2.Boost when using multiprocessing

淺唱寂寞╮ 提交于 2019-12-01 11:04:13
问题 I'm working on project named "Faciel Actions Units Detection" I'm using python2.7 and opencv 2.4 The error: pickle.PicklingError: Can't pickle <type 'cv2.Boost'>: it's not the same object as cv2.Boost A partial traceback, transcribed from a screenshot: Loading classifier for action unit 27 Traceback (most recent call last): File "C:\Python27\audetect-master\audetect-interactive.py", line 59, in <module> main() File "C:\Python27\audetect-master\audetect-interactive.py", line 18, in main active