Opencv Circle Color
This code below will draw a red circle at x,y coordinates
>>cv2.circle(frame,(x, y), 10, (0,0,255), -1)
But the right rbg code for red color should be (255,0,0). When I printed out the color name, it showed blue.
>>print webcolors.rgb_to_name((0,0,255)) >>blue
OpenCV uses BGR color space for representing colors. So, your color code :
(0, 0, 255)will be considered as
BGRcolor space by OpenCV.
If you want to draw blue circle you have to pass color code as
(255, 0, 0)
For more details about the color space in OpenCV go to this link
See also questions close to this topic
Python Kafka Streaming API - Binning
I am using python kafka stream binning example given in this, Python Kafka Streaming API
I am able to generate the data using generator.py file given under winton-kafka-streams/examples/binning/, whereas when i run the binning.py file from the same folder, i got the below issue. Could someone help me, to resolve this?
Change color of missing values in Seaborn heatmap
Consider the example of missing values in the Seaborn documentation:
corr = np.corrcoef(np.random.randn(10, 200)) mask = np.zeros_like(corr) mask[np.triu_indices_from(mask)] = True sns.heatmap(corr, mask=mask, vmax=.3, square=True)
How do I change the color of the missing values to, for example, black? The color of the missing values should be specified independent of the color scheme of the heatmap, it may not be present in the color scheme.
I tried adding
facecolor = 'black'but that didn't work. The color can be affected by e.g.
sns.axes_style("white")but it isn't clear to me how that can be used to set an arbitrary color.
Xpath + Scrapy + Python : data point couldn't be scraped
This is the XML structure:
<tr> <td> <font size="3"> <strong>Location:</strong> Hiranandani Gardens, Powai </font> </td> </tr>
I want to extract : Hiranandani Gardens, Powai
I tried with these:
Both returned an empty list.
Note: we must have to use the text of tag, i.e., "Location:". Otherwise, there are many other places on the site where the same XML structure is used. So, it'll fetch many more unnecessary things apart from the desired value if the text of strong tag is not used.
In Java OpenCV, how do I do the pre-element inverse operation on a Mat?
I'm trying out the Moving Least Squares algorithm, and I found some codes for it in C++, so I'm working in translating it to Java. There's just one thing I'm having trouble with: some of the code contains
Mat. This is the Pre-element inverse operation on the
Matobject, I think.
What is its equivalent in Java OpenCV? Because
Core.divide(1, mu, temp)doesn't seem to do that [the 1 corresponds to the scale].
Only find contour without child
I have used cv2.findContours on an image. After that, I have extracted the contour and hierarchy information. From there, how do I filter and draw only contours without child (which from my understanding has a value of -1 in the 3rd column in the hierarchy array)?
below is my code:my image
from imutils import perspective from imutils import contours import numpy as np import imutils import cv2 img = cv2.imread('TESTING.png') imgs = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) edged = imgs cnts = cv2.findContours(edged,cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) hierarchy = cnts ChildContour = hierarchy [0, :,2] WithoutChildContour = (ChildContour==-1).nonzero() cntsA = cnts if imutils.is_cv2() else cnts if not cntsA: print ("no contours") (cntsB, _) = contours.sort_contours(cntsA) orig = cv2.imread('TESTING.png') for c in cntsB: if cv2.contourArea(c) < 100: continue box = cv2.minAreaRect(c) box = cv2.boxPoints(box) if imutils.is_cv2() else cv2.boxPoints(box) box = np.array(box, dtype="int") box = perspective.order_points(box) cv2.drawContours(orig, [box.astype("int")], -1, (0, 255, 0), 2) screen_res = 972, 648 scale_width = screen_res / img.shape scale_height = screen_res / img.shape scale = min(scale_width, scale_height) window_width = int(img.shape * scale) window_height = int(img.shape * scale) cv2.namedWindow('Image', cv2.WINDOW_NORMAL) cv2.resizeWindow('Image', window_width, window_height) cv2.imshow("Image", orig) cv2.waitKey(0) cv2.destroyAllWindows()
Parameter "triangulatedPoints" of recoverPose and math behind it
cv::recoverPose has parameter "triangulatedPoints" as seen in documentation, though math behind it is not documented, even in sources (relevant commit on github). When I use it, I get this matrix in following form:
[0.06596200907402348, 0.1074107606919504, 0.08120752154556411, 0.07162400555712592, 0.1112415181779849, 0.06479560707001968, 0.06812069103377787, 0.07274771866295617, 0.1036230973846902, 0.07643884790206311, 0.09753859499789987, 0.1050111597547035, 0.08431322508162108, 0.08653721971228882, 0.06607013741719928, 0.1088621999959361, 0.1079215237863785, 0.07874160849424018, 0.07888037486261903, 0.07311940086190356; -0.3474319603010109, -0.3492386196164926, -0.3592673043398864, -0.3301695131649525, -0.3398606744869519, -0.3240186574427479, -0.3302508442361889, -0.3534091474425142, -0.3134288005980755, -0.3456284001726975, -0.3372514921152191, -0.3229005408417835, -0.3156005118578394, -0.3545418178651592, -0.3427899760859008, -0.3552801904337188, -0.3368860879000375, -0.3268499974874541, -0.3221050630233929, -0.3395139819250934; -0.9334091581425227, -0.9288726274060354, -0.9277125424980246, -0.9392374374147775, -0.9318967835907961, -0.941870018271934, -0.9394698966781299, -0.9306592884695234, -0.9419749503870455, -0.9332801148509925, -0.9343740431697417, -0.9386198310107222, -0.9431781968459053, -0.9290466865633286, -0.9351167772249444, -0.9264105322194914, -0.933362882155191, -0.9398254944757025, -0.9414486961893244, -0.935785675955617; -0.0607238817598344, -0.0607532477465341, -0.06067768097603395, -0.06075467523485482, -0.06073245675798231, -0.06078081616640227, -0.06074754785132623, -0.0606879948481664, -0.06089198212719162, -0.06071522666667255, -0.06076842109618678, -0.06083346023742937, -0.06084805655000008, -0.0606931888685702, -0.06071558440082779, -0.06073329803512636, -0.06078189449161094, -0.06080195858434526, -0.06083228813425822, -0.06073695721101467]
e.g. 4x20 matrix (in this case there were 20 points). I want to convert this data to std::vector in order to use it in solvePnP. How to do it, what is the math here? Thanks!
- Find the weight of an animal using this image
Could not find a version that satisfies the requirement cv2
Obviously, I'm new to these problems, but I have a weird problem:
I'm using MacOS and I'm using Mac Terminal.
opencvand even I saw its version and I was able to import
cv2, but I wonder why I'm not able to install
I tried, but
pycharmgives me this error:
(Could not find a version that satisfies the requirement cv2 (from versions:
No matching distribution found for cv2)
and it also says
you are using pip version 10.0.1 however version 18.0 is available
It's really ridiculous, because I updated
pipto version 18, but apparently
Does anyone know how to fix these errors?
"DLL load failed" when import cv2 (opencv)
i spent many hours to solve this problem but i can't find soloution , please any clue that you know share with me.
in [windows server 2012 R2 x64, python 3.7 64x]
pip install opencv-contrib-python
installed without any error .
and when i try to import it
show me this error :
Traceback (most recent call last): File "test.py", line 1, in <module> import cv2 File "C:\Program Files\Python37\lib\site-packages\cv2\__init__.py", line 3, in <module> from .cv2 import * ImportError: DLL load failed: The specified module could not be found.
and i see another topics about this error but their soloution is not work for me :
- DLL load failed error when importing cv2
- Failure to import cv2 in python : DLL load failed
- and a lot of pages in here
some of them say about that problem because anaconda , and i don't have anaconda even . and many say that problem 32 or 64 version , i try both and disappointment . many about system variables...
what dll failed to load? cv2? why ?
what i try till now:
- change python version : 3.5, 3.7, 2.7 in 86x and 64x (uninstall complete last version and delete all remain files in program files ... then install new one)
- try with another packages like : opencv-python, opencv-contrib, try install specific versions with .whl (in some topic i read about this so install numpy-1.14.5+mkl-cp37-cp37m-win_amd64.whl and opencv_python-3.4.3+contrib-cp37-cp37m-win_amd64.whl but anything not change)
- import numpy before cv2 for every test
- installed Microsoft Visual C++ 2015 Redistributable Update 3 , 2008 , 2010 , 2017 for 64x
please help me.