Androwish-相机图像处理

时间:2020-10-11 22:21:40

标签: android image camera processing tcltk

我是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
   }
  }
 }
}

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

非常感谢。

0 个答案:

没有答案