小编Gia*_*fra的帖子

处理OpenCV 2.4中的轮廓和边界矩形 - python 2.7

我正在使用openCv和python,我正在处理结构分析和形状描述符.我找到了这个博客:http://opencvpython.blogspot.it/2012/06/contours-2-brotherhood.html 这是非常有帮助的,我尝试用黑白图像绘制一个边界矩形,它的工作原理.但是现在从我提取的图像,例如,黄色和我想要绘制一个边界矩形.问题是黑白图像不均匀,有一些噪音,而且代码不能识别整个形状.

原始图像

黑白图像

最终形象

这是代码:

import numpy as np
import cv2

im = cv2.imread('shot.bmp')
hsv_img = cv2.cvtColor(im, cv2.COLOR_BGR2HSV)
COLOR_MIN = np.array([20, 80, 80],np.uint8)
COLOR_MAX = np.array([40, 255, 255],np.uint8)
frame_threshed = cv2.inRange(hsv_img, COLOR_MIN, COLOR_MAX)
imgray = frame_threshed
ret,thresh = cv2.threshold(frame_threshed,127,255,0)
contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
cnt=contours[0]
x,y,w,h = cv2.boundingRect(cnt)
cv2.rectangle(im,(x,y),(x+w,y+h),(0,255,0),2)
cv2.imshow("Show",im)
cv2.waitKey()
cv2.destroyAllWindows()
Run Code Online (Sandbox Code Playgroud)

opencv image-processing python-2.7 opencv-contour

19
推荐指数
1
解决办法
5万
查看次数

如何使用python2.7和opencv2.4显示全屏图像

我试图用python和opencv创建一种图像播放器.我显示的图像在我的屏幕上是相同的分辨率,我想在全屏模式下显示它们(没有底部的窗口栏和顶部的图像栏).

我也接受建议,以改善我的"var"使用计数器显示图像:)

谢谢

def main():
    var= 0
    while True:
        print 'loading images...'
        if var==0:
            img =  cv2.imread('2-c.jpg')
            var=var+1
        else:
            img =  cv2.imread('2-d.jpg')
        cv2.imshow("test",img)
        key=cv2.waitKey(0)
        if key==27:
            break
Run Code Online (Sandbox Code Playgroud)

编辑:我发布了一个图像,也许我可以更好地解释自己:http: //i39.tinypic.com/mhw1ev.jpg http://i39.tinypic.com/mhw1ev.jpg 你可以看到仍有蓝色条在上面

opencv python-2.7

13
推荐指数
3
解决办法
3万
查看次数

如何在JFrame/JPanel中可视化控制台java

我使用Swing库创建了一个Java程序.现在我想将我的控制台输出重定向到JFrame或JPanel.

java console swing jtextarea jtextcomponent

9
推荐指数
2
解决办法
4万
查看次数

使用ui-select使用量角器进行测试

我正在尝试用量角器测试ui-select.在这个ui-select我有一个国家列表.我的HTML看起来像:

<ui-select ng-model="datiAnagrafici.countryOfBirth" name="countryOfBirth" theme="bootstrap" reset-search-input="true" append-to-body="true" required blur>
                <ui-select-match placeholder="paese di nascita">{{$select.selected.name}}</ui-select-match>
                <ui-select-choices repeat="country.code as country in countries | filter: {name:$select.search}">
                    <span ng-bind-html="country.name"></span>
                </ui-select-choices>
</ui-select>
Run Code Online (Sandbox Code Playgroud)

我的页面对象如下所示:

this.country = element(by.model('datiAnagrafici.countryOfBirth'));
this.fillForm = function(){
   this.country.sendKeys('IT');
}
Run Code Online (Sandbox Code Playgroud)

在我的spec文件中,我有:

it('should fill the form', function() {
  form.fillForm();
})
Run Code Online (Sandbox Code Playgroud)

但是当我运行我的测试时,ng-model没有填充发送的数据.你有什么建议吗?谢谢

javascript testing angularjs protractor angular-ui-select

6
推荐指数
1
解决办法
3426
查看次数

如何在$ state angularjs中的控制器之间使用ui路由器传递对象

我正在使用这台发电机.

我有我的用户模块:

require('angular/angular');
require('angular-ui-router');


angular.module('userModule', ['ui.router'])
    .config(['$stateProvider', function($stateProvider) {


    $stateProvider
        .state('utenti', {
            url: '/utenti',
            templateUrl: 'src/utenti/views/utenti.tpl.html',
            controller: 'RegistrationCrl',    
        })

        .state('access', {
            url: '/access',
            templateUrl: 'src/utenti/views/access.tpl.html',
            controller: 'AccessCtrl',
        });


}])
.controller('RegistrationCrl', require('./controllers/registrationLogin'))
.controller('AccessCtrl', require('./controllers/access'));
Run Code Online (Sandbox Code Playgroud)

在我的RegistrationCrl中,我使用服务来创建一个新成员:

module.exports = function($scope, User, Member, $state, $location,$rootScope, $stateParams){
        $scope.registration = function(form){
            if(!form.$valid ){
                console.log('input error');
                return;
            }
            else{
                console.log('valid form');

                Member.create($scope.newMember,
                    function(data){
                        $state.go('access', data); 
                    },
                    function(data){
                        console.log(data);
                    }
                );

            }
        };
    };
Run Code Online (Sandbox Code Playgroud)

我想在下一个与accessCtl相关的视图中使用该数据.我不想在我的URL中使用id并使用$ stateParams.

我的访问控制器是:

module.exports =  function($scope, User, Member, $state, $rootScope, $stateParams){
        console.log($state); …
Run Code Online (Sandbox Code Playgroud)

angularjs angular-ui-router

4
推荐指数
1
解决办法
7825
查看次数

如何在不损失质量的情况下放大java中的图像?

我正在使用Java中的图像.我有一组图像 - 比方说每个600x800像素.我将它们调整为100x100,然后在其上制作一些东西.现在我想在开始尺寸放大图像而不会丢失我的变化和像素质量.这可能吗?

java image image-resizing image-enlarge

1
推荐指数
1
解决办法
1185
查看次数

在firebase中存储一个很长的html文本

我正在使用带有离子的firebase。我有我想在其中放置 html 文本的归档文本,一切正常,直到我不得不添加一个很长的文本作为http://www.gutenberg.org/files/45334/45334-h/45334-h。 htm

在firebase中保存长文本是否有限制?

谢谢

firebase

0
推荐指数
1
解决办法
2045
查看次数