How to change the bounding box thickness and label text in yolov5? - computer-vision

I am using YOLOv5s for object detection on custom datasets, there are multiple objects in given video, sometimes label text and bounding box thickness looks very bad. how can I customize these things?

when using detect.py, pass in the following arguments to adjust the labels and bounding boxes:
--line-thickness 1
--hide-labels True
--hide-conf True
For the --line-thickness argument, pass in an integer value to adjust the thickness, for labels and confidence, they are set to False by default. Setting them to True will hide them.

Be careful using --hide-labels True or hide-conf True. Under certain circumstances you can encounter an ErrorMessage. Only --hide-labels and --hide-conf should work perfectly fine.
Here is a list of arguments you can use with detect.py.
detect.py [-h] [--weights WEIGHTS [WEIGHTS ...]] [--source SOURCE]
[--data DATA] [--imgsz IMGSZ [IMGSZ ...]]
[--conf-thres CONF_THRES] [--iou-thres IOU_THRES]
[--max-det MAX_DET] [--device DEVICE] [--view-img]
[--save-txt] [--save-conf] [--save-crop] [--nosave]
[--classes CLASSES [CLASSES ...]] [--agnostic-nms]
[--augment] [--visualize] [--update] [--project PROJECT]
[--name NAME] [--exist-ok] [--line-thickness LINE_THICKNESS]
[--hide-labels] [--hide-conf] [--half] [--dnn]

Related

Django postgresql postgis incorrect spatial lookup

I have the following model:
class Item(Model):
lat_lng = PointField(geography=True, null=True)
Item.objects.create(lat_lng=Point(-95.864468, 36.075450))
bbox1 = (-168.3984375, 25.16517336866393, -52.03125, 75.32002523220804)
bbox2 = (-145.1953125, 25.16517336866393, -52.03125, 63.07486569058663)
bbox1 contains bbox2, but Item.objects.filter(lat_lng__coveredby=Polygon.from_bbox(bbox1)) doesn't return the item, while Item.objects.filter(lat_lng__coveredby=Polygon.from_bbox(bbox2)) returns it.
Am I missing something?
UPDATE:
If I remove geographic=True, then everything works. What does this flag stands for?
When using geography, great circle arcs are used instead of straight lines. This remains true for the lines connecting the bounding box corners.
The premise that box1 contains box2 is false. They may intersect, but one is not wholly contained in the other.
Box1 is wider than box 2, so its southern boundary, represented as a great circle arc, will go norther than box 2 boundary, and therefore the point is located south of box 1 but within box 2.

How to modify meters or variables based on the value that the PROCESS plugin returns?

PROBLEM
I am using the Process plugin (https://docs.rainmeter.net/manual/plugins/process/) to determine what services are running on my system.
My current output:
The values (on/off) change appropriately, but I also want to change the text color based on the value returned. Here's an example that is working on my system (arrow.png has red tint whenever measure values are received):
According to an article that I read on the Rainmeter forums (https://forum.rainmeter.net/viewtopic.php?t=3335), the best approach was to add the font color as a variable and then modify it like so:
[Variables]
indicatorText=255,255,255,100
;___SQL SERVER___
[measureSQL]
Measure=Plugin
Plugin=Process.dll
ProcessName=sqlservr.exe
StringIndex=1
Substitute="-1":"OFF","1":"ON"
[measureSQLindicator]
Measure=Calc
Formula=[measureSQL]
;should change text color to green
IfAboveValue=0
IfAboveAction=!RainmeterSetVariable indicatorText 51,255,0
[styleTextRight]
StringCase=None
stringalign=Right
StringStyle=Bold
StringEffect=Shadow
FontEffectColor=0,0,0,20
FontColor=#indicatorText#
;___SQL___
[meterSQL]
Meter=String
MeasureName=measureSQL
MeterStyle=styleTextLeft
X=15
Y=40
W=97
H=60
Text="SQL Server"
[meterSQLValue]
Meter=String
MeasureName=measureSQL
MeterStyle=styleTextRight
X=195
Y=40
W=97
H=60
Text="%1"
I know that the "-1" and "1" returned by the Process plugin are strings and need to be converted to type int in order to be recognized by the if statements, but everything I've tried has not changed the color. (including this code)
QUESTION
How can I make the values returned by the Process plugin ("-1", "1") return as integers so that they can be recognized by my if statements?
Or is there a better way to change text color in Rainmeter?
You've probably moved on from this question, but here's my answer.
You were on the right track. The problem was that in measureSQL, you were substituting -1 and 1 with ON and OFF, which AboveValue cannot measure. I removed the Substitute and AboveValue, and replaced them with an IfCondition and two MeterStyles. The MeterStyles replace the need for a variable, so you don't need to use DynamicVariables.
[MeasureSQLStatus]
Measure=Plugin
Plugin=Process.dll
ProcessName=sqlservr.exe
[ToggleSQLStatusText]
Measure=Calc
Formula=[measureSQL]
;should change text color to green
IfCondition=MeasureSQLStatus > 0
IfTrueAction=[!SetOption ProcessStatusText MeterStyle styleONText]
IfFalseAction=[!SetOption ProcessStatusText MeterStyle styleOFFText]
[StyleONText]
FontColor=51,255,0,255
Text="ON"
[StyleOFFText]
FontColor=255,255,255,100
Text="OFF"
[ProcessNameText]
Meter=String
MeasureName=measureSQL
MeterStyle=styleTextLeft
X=15
Y=40
W=97
H=60
Text="SQL Server"
[ProcessStatusText]
Meter=String
StringCase=None
stringalign=Right
StringStyle=Bold
StringEffect=Shadow
FontEffectColor=0,0,0,20
X=195
Y=40
W=97
H=60

How can I set the color of a specific line in a libgdx list?

I am developing a list and I want to highlight certain lines by showing the font color in red. Is this possible?
EDIT:
Ok, here a simplified version of my code:
Skin defListSkin = new Skin(Gdx.files.internal("data/uiskin.json"));
List listHistory = new List<String>(defSkin);
// Here I set the general font color for the list
List.ListStyle listStyle = listHistory.getStyle();
listStyle.font = fontList;
listStyle.fontColorUnselected = Color.LIGHT_GRAY;
listHistory.setStyle(listStyle);
String[] items = new String[20];
// Example of item[]
// item[0]: "John 12"
// item[1]: "Amy -3" <-- I want certain lines to appear in red (e.g. those with negative numbers)
// Populate the list
listHistory.setItems(items);
// Drawing the list (actual draw happens in render() of course)
Table myTable = new Table();
myTable.add(listHistory);
stage.addActor(myTable);
Use the Color Markup Language that Libgdx supports.
The markup syntax is really simple but still versatile:
[name] Sets the color by name. There are a few predefined colors, see the Colors.reset() method for an exhaustive list. Users can define their own colors through the methods of the Colors class.
[#xxxxxxxx] Sets the color specified by the hex value xxxxxxxx in the form RRGGBBAA where AA is optional and defaults to 0xFF.
[] Sets the color to the previous color (kind of optional end tag)
[[ Escapes the left bracket.
Markup is disabled by default. Use the public member font.getData().markupEnabled to turn it on/off.
Reference: https://github.com/libgdx/libgdx/wiki/Color-Markup-Language
If you want a more complex html like markup you can use those templates: https://github.com/czyzby/gdx-lml, live tests: http://czyzby.github.io/gdx-lml-tests/
I know what you mean, and I don't think it is possible. The list items are all linked to the same listStyle, and the only way to change the color of the list items is to make a new style for listHistory and change the font color of this style, however if you do this, it changes every item in the list to that new font color. My suggestion would be to create two separate lists and two separate ListStyles and the lines you want red be in one list and have one style and the lines you don't want to be red be in another list and have a different style. Hope this helps

Error "'Quiver' object has no attribute 'shape'"

I am using the Python Quiver function to combine u-velocity and v-velocity values into a vector map. I have semi-successfully combined the two arrays by using the quiver function within the colormesh() function, and my code returns a B&W plot of the data, but I get an error message "'Quiver' object has no attribute 'shape'". The data plot also seems to not allow the landmass/ocean commands to plot (or if I put those commands before the colormesh() command, then the quiver() command doesn't work). Also, I can't seem to add color or size to the quiver arrows. Why am I still getting sort of successful plotting, if I'm getting this error message? How can I fix it? I tried making a quiver array and then just plotting the name of that in the colormesh(), but that didn't work, either.
Thank you!!
m = Basemap(llcrnrlon=-120,llcrnrlat=32,urcrnrlon=-116,urcrnrlat=35,
resolution='l',projection='stere',
lat_0=32.5,lon_0=-117.)
fig = plt.figure(figsize=(10,10))
plt.figtext(.45,.15,'Figure 1. Avg. velocity from CORDC HF Radar avg. June 1, 2013',fontsize=12,ha='center')
x, y = m(lon,lat)# define color map
cmap = plt.cm.hsv
cs = m.pcolormesh(x,y,quiver(lon[0:230],lat[0:230],u_nanmean_mask,v_nanmean_mask),shading='gouraud',cmap=cm.RdYlBu,vmin=-0.10,vmax=0.12)
m.drawcoastlines()
m.fillcontinents(color='#989865',lake_color='w')
m.drawmapboundary(fill_color='w')
m.drawparallels(np.arange(-80.,81.,5.),labels=[0,1,1,0])
m.drawmeridians(np.arange(-180.,180.,5.),labels=[1,0,0,1])

How do I supply a British National Grid reference as WKT to GeoDjango?

I'm trying to insert some National Grid references into a Django PointField defined as follows:
oscode = models.PointField(srid=27700, null=True, blank=True)
However, I don't know how to format them correctly in WKT. This is what I get if I try simply using a basic National Grid reference, TR3241:
INSERT INTO places (placeid, structidx, subidx, county, name, oscode) VALUES ('10', '1', '1', 'Kent', 'Dover', 'TR3241');
psycopg2.InternalError: parse error - invalid geometry
LINE 1: ...'1', 'Kent', 'D1', 'Eastry', 'Bewsbury', 'Dover', 'TR3241', ...
^
HINT: You must specify a valid OGC WKT geometry type such as POINT, LINESTRING or POLYGON
And this is what I get if I (guessing wildly after reading up on WKT!) use POINT(TR3241):
psycopg2.InternalError: parse error - invalid geometry
LINE 1: ...'1', 'Kent', 'D1', 'Eastry', 'Bewsbury', 'Dover', 'POINT(TR3...
^
HINT: "POINT(" <-- parse error at position 6 within geometry
How do I format the grid ref correctly?
You would just need something like this, assuming a point with lon1 lat1:
insert into geography_table (name, geometry_field) values ('Chez Francois',\
ST_GeomFromText('POINT(lon1 lat1)', 27700));
It looks like your geometry column is called oscode; to check use psql mydb and hit \d. You should see a list of all tables, the one(s) you are interested in will be listed as type geometry. There should be a line at the bottom something like "enforce_srid_oscode" CHECK (st_srid(oscode) = 27700).
The big picture bit that may be throwing you off is that these records are just regular database tables, with at least one column containing details about some geometry on Earth. The inserts on these geometric values must be geometric types, and the way you get from (relatively) plain English to these geometries is with a geometry constructor.