本文整理匯總了Golang中github.com/lazywei/go-opencv/opencv.IplImage.Width方法的典型用法代碼示例。如果您正苦於以下問題:Golang IplImage.Width方法的具體用法?Golang IplImage.Width怎麽用?Golang IplImage.Width使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/lazywei/go-opencv/opencv.IplImage
的用法示例。
在下文中一共展示了IplImage.Width方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: ProcessImage
func ProcessImage(img *opencv.IplImage, win *opencv.Window, pos int) error {
w := img.Width()
h := img.Height()
// Create the output image
cedge := opencv.CreateImage(w, h, opencv.IPL_DEPTH_8U, 3)
defer cedge.Release()
// Convert to grayscale
gray := opencv.CreateImage(w, h, opencv.IPL_DEPTH_8U, 1)
edge := opencv.CreateImage(w, h, opencv.IPL_DEPTH_8U, 1)
defer gray.Release()
defer edge.Release()
opencv.CvtColor(img, gray, opencv.CV_BGR2GRAY)
opencv.Smooth(gray, edge, opencv.CV_BLUR, 3, 3, 0, 0)
opencv.Not(gray, edge)
// Run the edge detector on grayscale
opencv.Canny(gray, edge, float64(pos), float64(pos*3), 3)
opencv.Zero(cedge)
// copy edge points
opencv.Copy(img, cedge, edge)
win.ShowImage(img)
return nil
}
示例2: ProcessImage
func ProcessImage(img *opencv.IplImage, gradeOfCanny int) *opencv.IplImage {
w := img.Width()
h := img.Height()
// Create the output image
cedge := opencv.CreateImage(w, h, opencv.IPL_DEPTH_8U, 3)
//defer cedge.Release()
// Convert to grayscale
gray := opencv.CreateImage(w, h, opencv.IPL_DEPTH_8U, 1)
edge := opencv.CreateImage(w, h, opencv.IPL_DEPTH_8U, 1)
//newimage := opencv.CreateImage(w, h, opencv.IPL_DEPTH_8U, 1)
defer gray.Release()
defer edge.Release()
opencv.CvtColor(img, gray, opencv.CV_BGR2GRAY)
opencv.Smooth(gray, edge, opencv.CV_BLUR, 3, 3, 0, 0)
opencv.Not(gray, edge)
// Run the edge detector on grayscale
opencv.Canny(gray, edge, float64(gradeOfCanny), float64(gradeOfCanny*3), 3)
opencv.Zero(cedge)
// copy edge points
opencv.Copy(img, cedge, edge)
return cedge
}
示例3: ToImage
func ToImage(img *opencv.IplImage) image.Image {
out := image.NewNRGBA(image.Rect(0, 0, img.Width(), img.Height()))
if img.Depth() != opencv.IPL_DEPTH_8U {
return nil // TODO return error
}
for y := 0; y < img.Height(); y++ {
for x := 0; x < img.Width(); x++ {
s := img.Get2D(x, y).Val()
b, g, r, a := s[2], s[1], s[0], s[3]
c := color.NRGBA{uint8(b), uint8(g), uint8(r), uint8(a)}
out.Set(x, y, c)
}
}
return out
}
示例4: DetectFacialFeatures
func (detector *FaceDetector) DetectFacialFeatures(image *opencv.IplImage, faceCoords []pixelCoord) faces {
var faces = make(faces, 0)
for _, faceCoord := range faceCoords {
//Lets find us some eyes
leftEyes, rightEyes := detector.DetectEyes(image, &faceCoord)
if len(leftEyes) == 0 || len(rightEyes) == 0 {
//No eyes found, lets flop the picture and check again
fmt.Println("Flopping Picture to look for eyes")
floppedImage := opencv.DecodeImageMem(FlopImage(ToByteBuffer(image)))
floppedFaceCoords := faceCoord
floppedFaceCoords.Flop(pixelCoord{width: image.Width(), height: image.Height()})
floppedLeftEyes, floppedRightEyes := detector.DetectEyes(floppedImage, &floppedFaceCoords)
if len(leftEyes) == 0 {
floppedRightEyes.FlopEmAll(pixelCoord{width: image.Width(), height: image.Height()})
leftEyes = append(leftEyes, floppedRightEyes...)
}
if len(rightEyes) == 0 {
floppedLeftEyes.FlopEmAll(pixelCoord{width: image.Width(), height: image.Height()})
leftEyes = append(rightEyes, floppedLeftEyes...)
}
}
leftEye, rightEye := FindBestEyes(leftEyes, rightEyes)
faces = append(faces, face{
coord: faceCoord,
eye_left: leftEye,
eye_right: rightEye,
})
}
fmt.Println(faces)
return faces
}
示例5: main
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
_, currentfile, _, _ := runtime.Caller(0)
cascade := path.Join(path.Dir(currentfile), "haarcascade_frontalface_alt.xml")
window := opencv.NewWindowDriver()
camera := opencv.NewCameraDriver("tcp://192.168.1.1:5555")
ardroneAdaptor := ardrone.NewAdaptor()
drone := ardrone.NewDriver(ardroneAdaptor)
work := func() {
detect := false
drone.TakeOff()
var image *cv.IplImage
camera.On(opencv.Frame, func(data interface{}) {
image = data.(*cv.IplImage)
if !detect {
window.ShowImage(image)
}
})
drone.On(ardrone.Flying, func(data interface{}) {
gobot.After(1*time.Second, func() { drone.Up(0.2) })
gobot.After(2*time.Second, func() { drone.Hover() })
gobot.After(5*time.Second, func() {
detect = true
gobot.Every(300*time.Millisecond, func() {
drone.Hover()
i := image
faces := opencv.DetectFaces(cascade, i)
biggest := 0
var face *cv.Rect
for _, f := range faces {
if f.Width() > biggest {
biggest = f.Width()
face = f
}
}
if face != nil {
opencv.DrawRectangles(i, []*cv.Rect{face}, 0, 255, 0, 5)
centerX := float64(image.Width()) * 0.5
turn := -(float64(face.X()) - centerX) / centerX
fmt.Println("turning:", turn)
if turn < 0 {
drone.Clockwise(math.Abs(turn * 0.4))
} else {
drone.CounterClockwise(math.Abs(turn * 0.4))
}
}
window.ShowImage(i)
})
gobot.After(20*time.Second, func() { drone.Land() })
})
})
}
robot := gobot.NewRobot("face",
[]gobot.Connection{ardroneAdaptor},
[]gobot.Device{window, camera, drone},
work,
)
robot.Start()
}
示例6: HoughCirclesWithParams
func HoughCirclesWithParams(img *opencv.IplImage, dp float64, min_dist float64, param_1 float64, param_2 float64, min_radius int, maxradius int) []opencv.CircleStruct {
var gray = opencv.CreateImage(img.Width(), img.Height(), opencv.IPL_DEPTH_8U, 1)
opencv.CvtColor(img, gray, opencv.CV_BGR2GRAY)
return opencv.HoughCircles(gray, dp, min_dist, param_1, param_2, 1, 500)
}
示例7: HoughCircles1
func HoughCircles1(img *opencv.IplImage) []opencv.CircleStruct {
var gray = opencv.CreateImage(img.Width(), img.Height(), opencv.IPL_DEPTH_8U, 1)
opencv.CvtColor(img, gray, opencv.CV_BGR2GRAY)
return opencv.HoughCircles(gray, 15, 100, 75, 5, 25, 500)
}
示例8: cloneGreyscale
func cloneGreyscale(im *opencv.IplImage) *opencv.IplImage {
w, h := im.Width(), im.Height()
g := opencv.CreateImage(w, h, opencv.IPL_DEPTH_8U, 1)
opencv.CvtColor(im, g, opencv.CV_BGR2GRAY)
return g
}