shapes

Shape Detection in python using OpenCV

老子叫甜甜 提交于 2019-11-26 19:39:23
问题 I'm working on a project in which I use OpenCV to detect shapes and their colors. There are 5 colors (red, green, yellow, blue and white) and 4 shapes (rectangle, star, circle and heart). I've been able to reliably discern the colors and I can detect the shapes when the image used is a drawn image like this using this code. Note, the image is for demonstration only, the range values in my code are not for these colors. import cv2 import numpy as np class Shape(): def __init__(self, color,

How to make gradient background in android

梦想与她 提交于 2019-11-26 19:15:59
I want to create gradient background where the gradient is in the top half and there's a solid color in the bottom half, like in this image below: I can't because the centerColor spreads out to cover the bottom and top. How can I make a background like the first image? How can I make small centerColor that's not spread out? This is code in XML of background button above. <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <gradient android:startColor="#6586F0" android:centerColor="#D6D6D6" android:endColor="#4B6CD6" android:angle="90"/> <corners

How to create a DataFrame of random integers with Pandas?

本秂侑毒 提交于 2019-11-26 18:57:42
问题 I know that if I use randn, import pandas as pd import numpy as np df = pd.DataFrame(np.random.randn(100, 4), columns=list('ABCD')) gives me what I am looking for, but with elements from a normal distribution. But what if I just wanted random integers? randint works by providing a range, but not an array like randn does. So how do I do this with random integers between some range? 回答1: numpy.random.randint accepts a third argument ( size ) , in which you can specify the size of the output

How to define a circle shape in an Android xml drawable file?

非 Y 不嫁゛ 提交于 2019-11-26 16:46:18
I have some problems finding the documentation of the definitions of shapes in XML for Android. I would like to define a simple circle filled with a solid color in an XML File to include it into my layout files. Sadly the Documentation on android.com does not cover the XML attributes of the Shape classes. I think I should use an ArcShape to draw a circle but there is no explanation on how to set the size, the color, or the angle needed to make a circle out of an Arc. This is a simple circle as a drawable in Android. <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas

How to save a Google maps overlay shape in the database?

孤人 提交于 2019-11-26 12:55:59
问题 I want to save a Google maps overlay shape in the database. This is my code. It works perfectly but I just need to save all_shapes array in the database. <html> <head> <style type=\"text/css\"> #map, html, body { padding: 0; margin: 0; height: 100%; } </style> <script type=\"text/javascript\" src=\"http://maps.google.com/maps/api/js?sensor=true&libraries=drawing,geometry\"></script> <script> var coordinates = []; var all_shapes = []; var selectedShape; </script> <script> function draw_shape()

Java make a directed line and make it move

╄→гoц情女王★ 提交于 2019-11-26 11:28:21
问题 I want to make a directed line and make it move. I am able to make a directed line and move the line but the arrow get displaced while i move the line This is my paint method Line2D.Double line = new Line2D.Double(startX, startY, endX, endY); g2d.draw(line); tx.setToIdentity(); double angle = Math.atan2(line.y2 - line.y1, line.x2 - line.x1); tx.translate(line.x2, line.y2); tx.rotate((angle - Math.PI / 2d)); Graphics2D gClone = (Graphics2D) g2d.create(); gClone.setTransform(tx); Polygon

Java check if two rectangles overlap at any point

感情迁移 提交于 2019-11-26 09:37:31
问题 I have multiple rectangles and one special rectangle: the selection rect. I want to check for each rectangle if the rectangle contains at least one point which is inside the selection rectangle. Here is an image for clarity: 回答1: This will find if the rectangle is overlapping another rectangle: public boolean overlaps (Rectangle r) { return x < r.x + r.width && x + width > r.x && y < r.y + r.height && y + height > r.y; } 回答2: We can determine a rectangle with only one of its diagonal. Let's

Multi-gradient shapes

拥有回忆 提交于 2019-11-26 09:15:32
I'd like to create a shape that's like the following image: Notice the top half gradients from color 1 to color 2, but theres a bottom half that gradients from color 3 to color 4. I know how to make a shape with a single gradient, but I'm not sure how to split a shape into two halves and make 1 shape with 2 different gradients. Any ideas? kcoppock I don't think you can do this in XML (at least not in Android), but I've found a good solution posted here that looks like it'd be a great help! ShapeDrawable.ShaderFactory sf = new ShapeDrawable.ShaderFactory() { @Override public Shader resize(int

How to make gradient background in android

若如初见. 提交于 2019-11-26 06:53:05
问题 I want to create gradient background where the gradient is in the top half and there\'s a solid color in the bottom half, like in this image below: I can\'t because the centerColor spreads out to cover the bottom and top. How can I make a background like the first image? How can I make small centerColor that\'s not spread out? This is code in XML of background button above. <shape xmlns:android=\"http://schemas.android.com/apk/res/android\" android:shape=\"rectangle\" > <gradient android

How to define a circle shape in an Android xml drawable file?

☆樱花仙子☆ 提交于 2019-11-26 04:29:02
问题 I have some problems finding the documentation of the definitions of shapes in XML for Android. I would like to define a simple circle filled with a solid color in an XML File to include it into my layout files. Sadly the Documentation on android.com does not cover the XML attributes of the Shape classes. I think I should use an ArcShape to draw a circle but there is no explanation on how to set the size, the color, or the angle needed to make a circle out of an Arc. 回答1: This is a simple