Androwish-相机图像处理

问题描述

我是Androwish的新手,但是对tcl / tk有一定的经验。我正在尝试让前置摄像头获取图像并将其处理为黑白比例。我的代码如下:

wm attributes . -fullscreen 1
. configure -bg black

sdltk screensaver off

set ok 0

destroy .label
borg camera close
catch {image delete img}
image create photo img  -width 640 -height 480
image create photo img2 -width 640 -height 480
image create photo img3 -width 640 -height 480
borg camera open 1
borg camera parameters picture-size 640x480 jpeg-quality 80
bind . <<ImageCapture>> {if {$ok == 0} {borg camera image img; img2 copy img; set ok 1}}
borg camera start
pack [label .label  -image img  -background blue] -side top -fill both -expand yes
pack [label .label2 -image img3 -background red]  -side top -fill both -expand yes

while {1} {
 if {$ok == 1} {
  imageDetectOBJ img2 img3
  set ok 0
 }
 update
}

proc {imageDetectOBJ} {img img2} {
 set w [image width $img]
 set h [image height $img]
  
 for {set y 0} {$y < $h} {incr y} {
  for {set x 0} {$x < $w} {incr x} {
   set lc [$img get $x $y]
   
   if {([lindex $lc 0] > 126) || ([lindex $lc 1] > 126) || ([lindex $lc 2] > 126)} {
    $img2 put white -to $x $y
   } else {
    $img2 put black -to $x $y
   }
  }
 }
}

代码无法运行,给人的印象是,在要渲染图像时,我试图操纵它。我该如何工作?

非常感谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)