我有以下图片:
我想使用cv::inRange
方法和HSV颜色空间检测红色矩形.
int H_MIN = 0;
int H_MAX = 10;
int S_MIN = 70;
int S_MAX = 255;
int V_MIN = 50;
int V_MAX = 255;
cv::cvtColor( input, imageHSV, cv::COLOR_BGR2HSV );
cv::inRange( imageHSV, cv::Scalar( H_MIN, S_MIN, V_MIN ), cv::Scalar( H_MAX, S_MAX, V_MAX ), imgThreshold0 );
Run Code Online (Sandbox Code Playgroud)
我已经创建了动态轨迹栏以便更改HSV的值,但是我无法获得所需的结果.
是否有关于使用最佳值(也许是过滤器)的建议?
我的JSON是:
[
{
"distance":32,
"stationCode":"MIG",
"name":"Midghat",
"platforms":"2"
},
{
"distance":32,
"stationCode":"MIG",
"name":"Midghat",
"platforms":"2"
},
{
"distance":69,
"stationCode":"MDDP",
"name":"Mandideep",
"platforms":"2"
},
{
"distance":69,
"stationCode":"MDDP",
"name":"Mandideep",
"platforms":"2"
},
{
"distance":18,
"stationCode":"HBD",
"name":"Hoshangabad",
"platforms":"2"
},
{
"distance":18,
"stationCode":"HBD",
"name":"Hoshangabad",
"platforms":"2"
},
{
"distance":37,
"stationCode":"CHQ",
"name":"Choka",
"platforms":"2"
},
{
"distance":37,
"stationCode":"CHQ",
"name":"Choka",
"platforms":"2"
},
{
"distance":85,
"stationCode":"HBJ",
"name":"Habibganj",
"platforms":"5"
},
{
"distance":85,
"stationCode":"HBJ",
"name":"Habibganj",
"platforms":"5"
},
{
"distance":0,
"stationCode":"ET",
"name":"ItarsiJn",
"platforms":"28"
},
{
"distance":8,
"stationCode":"PRKD",
"name":"Powerkheda",
"platforms":"2"
},
{
"distance":8,
"stationCode":"PRKD",
"name":"Powerkheda",
"platforms":"2"
}, …
Run Code Online (Sandbox Code Playgroud) 我正在尝试将canvas的drawImage
方法与视频源一起使用,但它在使用Chrome浏览器测试的Android 4.4.2中无效.
这是我的代码:
$(function() {
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
var video = document.getElementById('video');
var videoWidth;
var videoHeight;
var paused = false;
canvas.addEventListener('click', function() {
if (paused) {
video.play();
} else {
video.pause();
}
paused = !paused;
});
video.addEventListener("loadedmetadata", function() {
videoWidth = this.videoWidth || this.width;
videoHeight = this.videoHeight || this.height;
canvas.width = videoWidth;
canvas.height = videoHeight;
}, false);
video.addEventListener('play', function() {
var $this = this; // cache
(function loop() {
if ( ! $this.paused …
Run Code Online (Sandbox Code Playgroud) 我正在尝试从中选择一组选项中的第一个值 <mat-autocomplete ...>
export class ExampleComponent implements OnInit, AfterViewInit {
@ViewChildren('auto') matAutocomplete: QueryList<any>;
constructor(private cdr: ChangeDetectorRef) { }
ngAfterViewInit() {
this.foundItemsList.changes.subscribe(options => {
// ---> This simply works!
setTimeout(() => this.matAutocomplete.first._keyManager.setFirstItemActive(), 0);
// ---> This doesn't works?! No error shown, it just seems that the above function isn't called at all.
this.matAutocomplete.first._keyManager.setFirstItemActive()
this.cdr.detectChanges();
});
}
Run Code Online (Sandbox Code Playgroud)
https://github.com/angular/material2/blob/master/src/lib/autocomplete/autocomplete.ts
AFAIK,detectChanges
检查当前组件及其所有子组件的变化检测器是什么,对吗?但似乎它在上面的场景中不起作用.
我有以下数据库(简化):
CREATE TABLE `tracking` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`manufacture` varchar(100) NOT NULL,
`date_last_activity` datetime NOT NULL,
`date_created` datetime NOT NULL,
`date_updated` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `manufacture` (`manufacture`),
KEY `manufacture_date_last_activity` (`manufacture`, `date_last_activity`),
KEY `date_last_activity` (`date_last_activity`),
) ENGINE=InnoDB AUTO_INCREMENT=401353 DEFAULT CHARSET=utf8
CREATE TABLE `tracking_items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`tracking_id` int(11) NOT NULL,
`tracking_object_id` varchar(100) NOT NULL,
`tracking_type` int(11) NOT NULL COMMENT 'Its used to specify the type of each item, e.g. car, bike, etc',
`date_created` …
Run Code Online (Sandbox Code Playgroud) 我试图获得标签的宽度和高度,我使用以下标记:
<div class="masked" id="video_container">
<video id="video" loop="loop" muted="muted" tabindex="0" style="width: 100%; height: 100%;">
<source src="..." type="..."</source>
<source src="..." type="..."</source>
</video>
</div>
Run Code Online (Sandbox Code Playgroud)
关键部分是宽度和高度属性都设置为100%,当窗口改变时,视频的宽高比被保存,但我无法得到它的实际宽度和高度.
我尝试使用offsetWidth和offsetHeight属性获取值,但它们返回视频的实际大小.
编辑:
这是为我工作的代码段:
var videoActualWidth = video.getBoundingClientRect().width;
var videoActualHeight = video.getBoundingClientRect().height;
var aspect = videoActualWidth / videoActualHeight;
if (w / h > aspect) {
video.setAttribute("style", "height: 100%");
} else {
video.setAttribute("style", "width: 100%");
}
Run Code Online (Sandbox Code Playgroud)
谢谢!