我有一个活动,其中有不同视图中的3个复选框.这些复选框用于拾取颜色.
在DrawingView类中,我必须在我的画布上绘制所选的颜色.我想要的是将活动中的整数值传递给视图类并相应地设置绘制的颜色.使用吸气剂和二传手,但我得到黑色.我想这是因为颜色是在构造函数本身中设置的,当我选中任何框时它不会改变.
请参考这个在下面的代码更新
码:
MainActivity:此处选择颜色/复选框.绘图将在此活动本身的布局中完成.
carImageView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
drawingView=new DrawingView(carImageView.getContext());
drawingView=new DrawingView(carImageView.getContext(),null);
drawingView.setColor(color);
return false;
}
});
scratchesCb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b)
{
color=1;
chipsCb.setChecked(false);
dentsCb.setChecked(false);
}
}
});
chipsCb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b)
{
color=2;
scratchesCb.setChecked(false);
dentsCb.setChecked(false);
}
}
});
dentsCb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
if(b)
{
color=3; …
Run Code Online (Sandbox Code Playgroud) 不确定这是否是正确的询问方式,但请帮忙.我有一张凹陷车的图像.我必须处理它并突出凹痕并返回凹痕的数量.我能够很好地完成以下结果:
matlab代码是:
img2=rgb2gray(i1);
imshow(img2);
img3=imtophat(img2,strel('disk',15));
img4=imadjust(img3);
layer=img4(:,:,1);
img5=layer>100 & layer<250;
img6=imfill(img5,'holes');
img7=bwareaopen(img6,5);
[L,ans]=bwlabeln(img7);
imshow(img7);
I=imread(i1);
Ians=CarDentIdentification(I);
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试使用opencv执行此操作时,我得到了这个:
使用以下代码:
Imgproc.cvtColor(source, middle, Imgproc.COLOR_RGB2GRAY);
Imgproc.equalizeHist(middle, middle);
Imgproc.threshold(middle, middle, 150, 255, Imgproc.THRESH_OTSU);
Run Code Online (Sandbox Code Playgroud)
请告诉我如何在opencv中获得更好的结果,以及如何计算凹痕?我试过findcontour(),但它给出了一个非常大的数字.我也尝试过其他图像,但是我没有得到正确的结果.请帮忙.
我有一个用例,我需要验证一组由 | 分隔的值 。
我关注了https://github.com/hapijs/joi/issues/570但它引发了许多错误。我有什么办法可以做到这一点吗?
示例 - AA|BB|CC|DD
现在,我需要验证所有值(AA、BB、CC、DD)都是字符串。
我相信我不能使用正则表达式,因为它只会验证第一个值。
另外,我的代码中还有许多其他验证,因此我不希望循环验证过程。
如果我不清楚,请告诉我。谢谢!