OpenCV

python receiving image from socket stream

主宰稳场 提交于 2021-02-11 08:04:02
问题 I'm trying to send a frame and throw socket by python, using opencv . The image is sent as string stream but when i remake the image on the server,the bytes are not in the right order. Client code : import socket import numpy as np import cv2 UDP_IP = "127.0.0.1" UDP_PORT = 5005 cap = cv2.VideoCapture(1) sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) while 1: ret, frame = cap.read() cv2.imshow('client', frame) d = frame.flatten() s = d.tostring() #sock.sendall(s) #print len(s) for i

OpenCV 2.4 estimateAffine3D in Python

↘锁芯ラ 提交于 2021-02-11 07:40:04
问题 I'm trying to use the method cv2.estimateAffine3D but without success. Here is my code sample : import numpy as np import cv2 shape = (1, 4, 3) source = np.zeros(shape, np.float32) # [x, y, z] source[0][0] = [857, 120, 854] source[0][1] = [254, 120, 855] source[0][2] = [256, 120, 255] source[0][3] = [858, 120, 255] target = source * 10 retval, M, inliers = cv2.estimateAffine3D(source, target) When I try to run this sample, I obtain the same error as this other post here. I'm using OpenCV 2.4

OpenCV 2.4 estimateAffine3D in Python

自作多情 提交于 2021-02-11 07:39:40
问题 I'm trying to use the method cv2.estimateAffine3D but without success. Here is my code sample : import numpy as np import cv2 shape = (1, 4, 3) source = np.zeros(shape, np.float32) # [x, y, z] source[0][0] = [857, 120, 854] source[0][1] = [254, 120, 855] source[0][2] = [256, 120, 255] source[0][3] = [858, 120, 255] target = source * 10 retval, M, inliers = cv2.estimateAffine3D(source, target) When I try to run this sample, I obtain the same error as this other post here. I'm using OpenCV 2.4

How to implement Array in python Swig.?

守給你的承諾、 提交于 2021-02-11 06:31:19
问题 I am wrote sample C++ application. Now I am going communicate with Python through Swig. What I did Generated interface file for my function classify.i %module example %{ #include "Facdetect.h" %} %include "typemaps.i" %include "cstring.i" %include "cdata.i" %include <std_string.i> %apply unsigned char *{unsigned char *x}; %apply double *INOUT{double *y}; %include "Facdetect.h" Facdetect.h #include <iostream> class facedetect { public: void display(unsigned char *x,double *y); }; sample.cpp

How to implement Array in python Swig.?

∥☆過路亽.° 提交于 2021-02-11 06:30:25
问题 I am wrote sample C++ application. Now I am going communicate with Python through Swig. What I did Generated interface file for my function classify.i %module example %{ #include "Facdetect.h" %} %include "typemaps.i" %include "cstring.i" %include "cdata.i" %include <std_string.i> %apply unsigned char *{unsigned char *x}; %apply double *INOUT{double *y}; %include "Facdetect.h" Facdetect.h #include <iostream> class facedetect { public: void display(unsigned char *x,double *y); }; sample.cpp

How can I dilate a binary image without closing holes with OpenCV

妖精的绣舞 提交于 2021-02-11 06:01:41
问题 How can I apply dilation to the binary image on the left without closing the hole in the loop? I'm also interested in doing it efficiently. Context : I need to train a CNN to read handwritten digits. Believe it or not, the image on the left is supposed to be a 9. Since the dataset has a lot of 9s written that way I may have a chance at training a model to recognise it. I do need to apply some dilation though, in order to get the digit thickness to be similar to that of the digits fed into the

How can I dilate a binary image without closing holes with OpenCV

南笙酒味 提交于 2021-02-11 06:01:38
问题 How can I apply dilation to the binary image on the left without closing the hole in the loop? I'm also interested in doing it efficiently. Context : I need to train a CNN to read handwritten digits. Believe it or not, the image on the left is supposed to be a 9. Since the dataset has a lot of 9s written that way I may have a chance at training a model to recognise it. I do need to apply some dilation though, in order to get the digit thickness to be similar to that of the digits fed into the

taking images from webcam

穿精又带淫゛_ 提交于 2021-02-11 04:54:55
问题 I have this script to capture images from webcam, but it is not saving any image, I donot know why. I am getting this error " Traceback (most recent call last): File "C:/Users/Iram/.PyCharmCE2019.3/config/scratches/scratch_5.py", line 26, in gray = cv2.cvtColor(img_, cv2.COLOR_BGR2GRAY) cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor' [ WARN:0] global C:\projects\opencv-python

taking images from webcam

一个人想着一个人 提交于 2021-02-11 04:54:17
问题 I have this script to capture images from webcam, but it is not saving any image, I donot know why. I am getting this error " Traceback (most recent call last): File "C:/Users/Iram/.PyCharmCE2019.3/config/scratches/scratch_5.py", line 26, in gray = cv2.cvtColor(img_, cv2.COLOR_BGR2GRAY) cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor' [ WARN:0] global C:\projects\opencv-python

始于TensorFlow ,终于PyTorch

北慕城南 提交于 2021-02-11 03:19:39
点击上方 “ 小白学视觉 ”,选择加" 星标 "或“ 置顶 ” 重磅干货,第一时间送达 作者 | Scott Carey 译者 | Sambodhi 策划 | 刘燕 转自 | AI前线 为什么这三家公司最终都不约而同地放弃 TensorFlow ,而转向了 PyTorch? 本文最初发表于 InfoWorld,经 InfoWorld 授权,InfoQ 中文站翻译并分享。 深度学习框架 PyTorch 凭借其相对易用性,已经渗透到了企业中。本文提到的三家公司告诉我们,为什么他们选择 PyTorch 而不是 Google 著名的 TensorFlow 框架。 深度学习 是机器学习的一个子类别,它使用多层神经网络将历史上很难完成的机器任务——比如 图像识别、自然语言处理 和 机器翻译——实现大规模自动化。 自 2015 年以来,TensorFlow 就从 Google 中脱颖而出,在研究和商业领域成为最受欢迎的开源深度学习框架。但是 2016 年从 Facebook 诞生的 PyTorch 由于社区推动的易用性改进和越来越广泛的用例部署,而迅速 赶上TensorFlow。 在汽车行业,PyTorch 的应用尤为广泛——它可以应用于 Tesla 和 Lyft Level 5 等公司的实验性自动驾驶系统。该框架也被媒体公司用来对内容进行分类和推荐,并在工业应用中支持机器人。 Facebook