• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang opencv.NewWindow函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/lazywei/go-opencv/opencv.NewWindow函数的典型用法代码示例。如果您正苦于以下问题:Golang NewWindow函数的具体用法?Golang NewWindow怎么用?Golang NewWindow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NewWindow函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: loop

func loop(path string, paint, crosshair bool) {

	pictureFiles = GetFileNames(path)

	//	images := make([][]byte, len(pictureFiles))
	faceDetector := gofaces.NewFaceDetector()

	//	for i := 0; i < len(pictureFiles); i++ {

	//	}

	fmt.Println("Pictures: ", len(pictureFiles))

	for i := 0; i < len(pictureFiles); i++ {

		fmt.Println("Processing picture: ", pictureFiles[i])
		img := gofaces.GetNormalizedByteVectorFromFile(pictureFiles[i])
		faces := faceDetector.Detect(img)
		if len(faces) > 0 {
			if paint {
				img = gofaces.PaintFace(img, faces[0])
			}

			if faces[0].Eyes() > 1 {
				img = gofaces.AlignFaceInImage(img, faces[0])
			}

			if crosshair {
				img = gofaces.Crosshair(img)
			}

			cropface := gofaces.CropOutFace(img, faces[0])

			win := opencv.NewWindow("Face Detected")

			win.ShowImage(opencv.DecodeImageMem(cropface))
			opencv.WaitKey(0)
			win.Destroy()
		} else {
			win := opencv.NewWindow("No face found")

			win.ShowImage(opencv.DecodeImageMem(img))
			opencv.WaitKey(0)
			win.Destroy()
		}

	}
}
开发者ID:postfix,项目名称:gofaces,代码行数:48,代码来源:main.go


示例2: main

func main() {
	_, currentfile, _, _ := runtime.Caller(0)
	filename := path.Join(path.Dir(currentfile), "./images/gopher.png")
	if len(os.Args) == 2 {
		filename = os.Args[1]
	}

	image := opencv.LoadImage(filename)
	if image == nil {
		panic("LoadImage fail")
	}
	defer image.Release()

	win := opencv.NewWindow("Go-OpenCV")
	defer win.Destroy()

	win.SetMouseCallback(func(event, x, y, flags int) {
		fmt.Printf("event = %d, x = %d, y = %d, flags = %d\n",
			event, x, y, flags,
		)
	})
	win.CreateTrackbar("Thresh", 1, 100, func(pos int) {
		fmt.Printf("pos = %d\n", pos)
	})

	win.ShowImage(image)

	opencv.WaitKey(0)
}
开发者ID:kyokomi-sandbox,项目名称:sandbox,代码行数:29,代码来源:main.go


示例3: main

func main() {
	filename := "../images/lena.jpg"
	if len(os.Args) == 2 {
		filename = os.Args[1]
	}

	image := opencv.LoadImage(filename)
	if image == nil {
		panic("LoadImage fail")
	}
	defer image.Release()

	win := opencv.NewWindow("Go-OpenCV")
	defer win.Destroy()

	win.SetMouseCallback(func(event, x, y, flags int) {
		fmt.Printf("event = %d, x = %d, y = %d, flags = %d\n",
			event, x, y, flags,
		)
	})
	win.CreateTrackbar("Thresh", 1, 100, func(pos int) {
		fmt.Printf("pos = %d\n", pos)
	})

	win.ShowImage(image)

	opencv.WaitKey(0)
}
开发者ID:nfillot,项目名称:go-opencv,代码行数:28,代码来源:hellocv.go


示例4: main

func main() {
	var edge_threshold int

	win := opencv.NewWindow("Go-OpenCV Webcam")
	defer win.Destroy()

	cap := opencv.NewCameraCapture(0)
	if cap == nil {
		panic("can not open camera")
	}
	defer cap.Release()

	win.CreateTrackbar("Thresh", 1, 100, func(pos int, param ...interface{}) {
		edge_threshold = pos
	})

	fmt.Println("Press ESC to quit")
	for {
		if cap.GrabFrame() {
			img := cap.RetrieveFrame(1)
			if img != nil {
				ProcessImage(img, win, edge_threshold)
			} else {
				fmt.Println("Image ins nil")
			}
		}
		key := opencv.WaitKey(10)

		if key == 27 {
			os.Exit(0)
		}
	}
}
开发者ID:mstein11,项目名称:opencv-examples,代码行数:33,代码来源:webcam.go


示例5: NewWindowDriver

// NewWindowDriver creates a new window driver with specified name.
// It adds an start function to initialize window
func NewWindowDriver(name string) *WindowDriver {
	return &WindowDriver{
		name: name,
		start: func(w *WindowDriver) {
			w.window = cv.NewWindow(w.Name(), cv.CV_WINDOW_NORMAL)
		},
	}
}
开发者ID:ympons,项目名称:gobot,代码行数:10,代码来源:window_driver.go


示例6: TrackEyes

func TrackEyes(srcFile, destFile string) {
	var video = opencv.NewFileCapture(srcFile)

	var fourcc = opencv.FOURCC('m', 'p', '4', 'v')
	var fps = float32(video.GetProperty(opencv.CV_CAP_PROP_FPS))
	var size = opencv.Size{int(video.GetProperty(opencv.CV_CAP_PROP_FRAME_WIDTH)),
		int(video.GetProperty(opencv.CV_CAP_PROP_FRAME_HEIGHT))}

	if video == nil {
		panic("no file found with name: " + srcFile)
	}
	defer video.Release()

	win := opencv.NewWindow("Go-OpenCV Webcam")
	defer win.Destroy()

	_, currentfile, _, _ := runtime.Caller(0)
	var cascade = path.Join(path.Dir(currentfile), "/../cascades/haarcascade_eye_tree_eyeglasses.xml")
	var eyeMarker = NewEyeMarker(cascade)

	var imgs = []*opencv.IplImage{}
	var imgs2 = []*opencv.IplImage{}

	for {
		if video.GrabFrame() {
			img := video.RetrieveFrame(1)
			if img != nil {

				var copy = opencv.CreateImage(img.Width(), img.Height(), img.Depth(), img.Channels())
				opencv.Copy(img.Clone(), copy, nil)

				var markedImg = eyeMarker.MarkEyes(copy)

				imgs = append(imgs, markedImg)
				//win.ShowImage(imgs[len(imgs)-1])
			} else {
				fmt.Println("Image ins nil")
			}
		} else {
			break
		}
		key := opencv.WaitKey(10)

		if key == 27 {
			os.Exit(0)
		}
	}

	for i := 0; i < len(imgs2); i++ {
		win.ShowImage(imgs2[i])
	}
	log.Print("before write")
	NewVideoWriter(uint32(fourcc), fps, size).SaveAsVideo(imgs, "test.avi")
	os.Exit(0)
}
开发者ID:mstein11,项目名称:opencv-examples,代码行数:55,代码来源:eyeTracking.go


示例7: Calibrate

func (v *View) Calibrate() {
	win := opencv.NewWindow("Calibration")
	defer win.Destroy()

	overfunc := func(s string, index int) (string, int, func(pos int, param ...interface{})) {
		var ours string
		ours = fmt.Sprintf("%s%d", s, index)
		var myf func(pos int, param ...interface{})
		var pix int
		switch s {
		case "Top":
			myf = func(pos int, param ...interface{}) {
				v.Calibration.Circles[index].TopTangent = pos
			}
			pix = 1943
		case "Left":
			myf = func(pos int, param ...interface{}) {
				v.Calibration.Circles[index].LeftTangent = pos
			}
			pix = 2591
		case "Right":
			myf = func(pos int, param ...interface{}) {
				v.Calibration.Circles[index].RightTangent = pos
			}
			pix = 2591
		case "Bottom":
			myf = func(pos int, param ...interface{}) {
				v.Calibration.Circles[index].BottomTangent = pos
			}
			pix = 1943
		default:
			panic("None of them???")
		}
		return ours, pix, myf
	}

	for i := 0; i < 7; i++ {
		tours, tpix, tmyf := overfunc("Top", i)
		lours, lpix, lmyf := overfunc("Left", i)
		rours, rpix, rmyf := overfunc("Right", i)
		bours, bpix, bmyf := overfunc("Bottom", i)
		win.CreateTrackbar(tours, 0, tpix, tmyf)
		win.CreateTrackbar(lours, 0, lpix, lmyf)
		win.CreateTrackbar(rours, 0, rpix, rmyf)
		win.CreateTrackbar(bours, 0, bpix, bmyf)
	}

	//win.CreateTrackbar("Left5", 0, 2591, func(pos int, param ...interface{}) {
	//	v.Calibration.Circles[5].LeftTangent = pos
	//})
}
开发者ID:ArchieT,项目名称:3manchess,代码行数:51,代码来源:camget.go


示例8: CaptureFrames

func CaptureFrames() {
	var cam = opencv.NewCameraCapture(0)
	defer cam.Release()

	frames := []*opencv.IplImage{}
	//var writter = opencv.NewVideoWriter("test.avi", int(opencv.FOURCC('D','I','V','3')),20, 50, 50, 1)

	win := opencv.NewWindow("Go-OpenCV Webcam123")
	defer win.Destroy()
	for framesCounter := 0; framesCounter <= 25; framesCounter++ {
		log.Print(framesCounter)
		if cam.GrabFrame() || framesCounter > 25 {
			//            var frame = cam.RetrieveFrame(1)
			//            var img = ProcessImage(frame, 50)
			//            frames = append(frames, img)

			var frame = cam.RetrieveFrame(1)
			win.ShowImage(frame)
			//            var img3 = frame.ToImage()

			var imageHeader = opencv.CreateImage(frame.Width(), frame.Height(), frame.Depth(), frame.Channels())

			for i := 0; i < frame.Width(); i++ {
				for j := 0; j < frame.Height(); j++ {

					scalar := frame.Get2D(i, j)
					var bgra = scalar.Val()
					var newscalar = opencv.NewScalar(bgra[0], bgra[1], bgra[2], 1)
					imageHeader.Set2D(i, j, newscalar)

				}
			}
			//            var img3Opencv = opencv.FromImage(img3)

			var copy = opencv.CreateImage(frame.Width(), frame.Height(), frame.Depth(), frame.Channels())
			opencv.Copy(frame, copy, nil)
			//            frames = append(frames, img3Opencv)

			//win.ShowImage(imageHeader)

		}
	}

	var videoWritter = NewVideoWriter(opencv.FOURCC('D', 'I', 'V', '3'), 20, opencv.Size{frames[0].Width(), frames[0].Height()})
	videoWritter.SaveAsVideo(frames, "test.avi")

}
开发者ID:mstein11,项目名称:opencv-examples,代码行数:47,代码来源:captureFramesToFile.go


示例9: debug

func debug(path string) {
	faceDetector := gofaces.NewFaceDetector()

	picture := gofaces.GetNormalizedByteVectorFromFile(path)

	image := opencv.DecodeImageMem(picture)
	faceAreas := faceDetector.DetectFaces(image)
	faces := faceDetector.DetectFacialFeatures(image, faceAreas)

	picture = gofaces.PaintFaces(picture, faces)

	win := opencv.NewWindow("Debug Face Detection")
	defer win.Destroy()

	win.ShowImage(opencv.DecodeImageMem(picture))
	opencv.WaitKey(0)
}
开发者ID:postfix,项目名称:gofaces,代码行数:17,代码来源:main.go


示例10: one

func one(path string, paint bool) {
	faceDetector := gofaces.NewFaceDetector()

	picture := gofaces.GetNormalizedByteVectorFromFile(path)
	faces := faceDetector.Detect(picture)
	if paint {
		picture = gofaces.PaintFace(picture, faces[0])
	}
	picture = gofaces.AlignFaceInImage(picture, faces[0])
	picture = gofaces.CropOutFace(picture, faces[0])

	win := opencv.NewWindow("Face Detection")
	defer win.Destroy()

	win.ShowImage(opencv.DecodeImageMem(picture))
	opencv.WaitKey(0)
}
开发者ID:postfix,项目名称:gofaces,代码行数:17,代码来源:main.go


示例11: main

func main() {
	_, currentfile, _, _ := runtime.Caller(0)
	image := opencv.LoadImage(path.Join(path.Dir(currentfile), "../images/lena.jpg"))

	cascade := opencv.LoadHaarClassifierCascade(path.Join(path.Dir(currentfile), "haarcascade_frontalface_alt.xml"))
	faces := cascade.DetectObjects(image)

	for _, value := range faces {
		opencv.Rectangle(image,
			opencv.Point{value.X() + value.Width(), value.Y()},
			opencv.Point{value.X(), value.Y() + value.Height()},
			opencv.ScalarAll(255.0), 1, 1, 0)
	}

	win := opencv.NewWindow("Face Detection")
	win.ShowImage(image)
	opencv.WaitKey(0)
}
开发者ID:9nut,项目名称:go-opencv,代码行数:18,代码来源:face_detect.go


示例12: main

func main() {
	win := opencv.NewWindow("Go-OpenCV Webcam Face Detection")
	defer win.Destroy()

	cap := opencv.NewCameraCapture(0)
	if cap == nil {
		panic("cannot open camera")
	}
	defer cap.Release()

	cwd, err := os.Getwd()
	if err != nil {
		panic(err)
	}
	cascade := opencv.LoadHaarClassifierCascade(path.Join(cwd, "haarcascade_frontalface_alt.xml"))

	fmt.Println("Press ESC to quit")
	for {
		if cap.GrabFrame() {
			img := cap.RetrieveFrame(1)
			if img != nil {
				faces := cascade.DetectObjects(img)
				for _, value := range faces {
					opencv.Circle(img,
						opencv.Point{
							value.X() + (value.Width() / 2),
							value.Y() + (value.Height() / 2),
						},
						value.Width()/2,
						opencv.ScalarAll(255.0), 1, 1, 0)
				}

				win.ShowImage(img)
			} else {
				fmt.Println("nil image")
			}
		}
		key := opencv.WaitKey(1)

		if key == 27 {
			os.Exit(0)
		}
	}
}
开发者ID:9nut,项目名称:go-opencv,代码行数:44,代码来源:webcam_facedetect.go


示例13: MarkRoi

func MarkRoi() {

	//
	//    var fourcc = opencv.FOURCC('m','p','4','v')
	//    var fps = float32(video.GetProperty(opencv.CV_CAP_PROP_FPS))
	//    var size = opencv.Size{int(video.GetProperty(opencv.CV_CAP_PROP_FRAME_WIDTH)),
	//        int(video.GetProperty(opencv.CV_CAP_PROP_FRAME_HEIGHT))};
	//
	//    log.Print("fourcc: ", fourcc)
	//    log.Print("fps: ", fps)
	//    log.Print("size: ", size)
	//
	//    defer video.Release()

	win := opencv.NewWindow("Go-OpenCV Webcam")
	defer win.Destroy()

	win2 := opencv.NewWindow("rect cam: ")
	win2.Move(400, 0)
	defer win2.Destroy()

	_, currentfile, _, _ := runtime.Caller(0)
	var cascade = path.Join(path.Dir(currentfile), "/../cascades/haarcascade_eye_tree_eyeglasses.xml")
	var eyeMarker = NewEyeMarker(cascade)

	var cap = NewVideoCapture(path.Join(path.Dir(currentfile), "/../eyevid1.mp4"))
	//var cap = NewVideoCapture("")

	var rois []*opencv.Rect

	for {
		var frame = cap.GetFrame()
		if frame == nil {
			break
		}
		img := frame

		var copy = opencv.CreateImage(img.Width(), img.Height(), opencv.IPL_DEPTH_8U, 3)
		opencv.Copy(img, copy, nil)

		rois = eyeMarker.MarkEyesRects(copy)

		if len(rois) > 0 {
			log.Print(rois[0])
			copy.SetROI(*rois[0])
			copy = ProcessRoi(copy, 25)
			//var gray = opencv.CreateImage(copy.Width(),copy.Height(),opencv.IPL_DEPTH_8U,1)
			//copy.SetROI(*rois[0])

			var circels = HoughCircles1(copy)
			log.Print(circels)
			for i := 0; i < len(circels); i++ {

				var center = opencv.Point{rois[0].X() + int(circels[i].X), rois[0].Y() + int(circels[0].Y)}
				//var center = opencv.Point{int(circels[i].X),int(circels[0].Y)}
				opencv.Circle(img, center, int(circels[i].R), opencv.NewScalar(255, 0, 0, 1), 1, 1, 0)
				//src *IplImage, dp float64, min_dist float64, param1 float64, param2 float64, min_radius int, max_radius int
			}
			copy.ResetROI()
		}

		win.ShowImage(img)
		win2.ShowImage(copy)

		key := opencv.WaitKey(10)

		if key == 27 {
			os.Exit(0)
		}
	}

	os.Exit(0)
}
开发者ID:mstein11,项目名称:opencv-examples,代码行数:73,代码来源:markRoi.go


示例14: main

func main() {
	filename := "../images/fruits.jpg"
	if len(os.Args) == 2 {
		filename = os.Args[1]
	}

	img0 := opencv.LoadImage(filename)
	if img0 == nil {
		panic("LoadImage fail")
	}
	defer img0.Release()

	fmt.Print("Hot keys: \n",
		"\tESC - quit the program\n",
		"\tr - restore the original image\n",
		"\ti or ENTER - run inpainting algorithm\n",
		"\t\t(before running it, paint something on the image)\n",
	)

	img := img0.Clone()
	inpainted := img0.Clone()
	inpaint_mask := opencv.CreateImage(img0.Width(), img0.Height(), 8, 1)

	opencv.Zero(inpaint_mask)
	//opencv.Zero( inpainted )

	win := opencv.NewWindow("image")
	defer win.Destroy()

	prev_pt := opencv.Point{-1, -1}
	win.SetMouseCallback(func(event, x, y, flags int, param ...interface{}) {
		if img == nil {
			os.Exit(0)
		}

		if event == opencv.CV_EVENT_LBUTTONUP ||
			(flags&opencv.CV_EVENT_FLAG_LBUTTON) == 0 {
			prev_pt = opencv.Point{-1, -1}
		} else if event == opencv.CV_EVENT_LBUTTONDOWN {
			prev_pt = opencv.Point{x, y}
		} else if event == opencv.CV_EVENT_MOUSEMOVE &&
			(flags&opencv.CV_EVENT_FLAG_LBUTTON) != 0 {
			pt := opencv.Point{x, y}
			if prev_pt.X < 0 {
				prev_pt = pt
			}

			rgb := opencv.ScalarAll(255.0)
			opencv.Line(inpaint_mask, prev_pt, pt, rgb, 5, 8, 0)
			opencv.Line(img, prev_pt, pt, rgb, 5, 8, 0)
			prev_pt = pt

			win.ShowImage(img)
		}
	})
	win.ShowImage(img)
	opencv.WaitKey(0)

	win2 := opencv.NewWindow("inpainted image")
	defer win2.Destroy()
	win2.ShowImage(inpainted)

	for {
		key := opencv.WaitKey(20)
		if key == 27 {
			os.Exit(0)
		} else if key == 'r' {
			opencv.Zero(inpaint_mask)
			opencv.Copy(img0, img, nil)
			win.ShowImage(img)
		} else if key == 'i' || key == '\n' {
			opencv.Inpaint(img, inpaint_mask, inpainted, 3,
				opencv.CV_INPAINT_TELEA,
			)
			win2.ShowImage(inpainted)
		}
	}
	os.Exit(0)
}
开发者ID:nfillot,项目名称:go-opencv,代码行数:79,代码来源:inpaint.go


示例15: main

func main() {
	filename := "../images/lena.jpg"
	if len(os.Args) == 2 {
		filename = os.Args[1]
	}

	image := opencv.LoadImage(filename)
	if image == nil {
		panic("LoadImage fail")
	}
	defer image.Release()

	w := image.Width()
	h := image.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(image, gray, opencv.CV_BGR2GRAY)

	win := opencv.NewWindow("Edge")
	defer win.Destroy()

	win.SetMouseCallback(func(event, x, y, flags int, param ...interface{}) {
		fmt.Printf("event = %d, x = %d, y = %d, flags = %d\n",
			event, x, y, flags,
		)
	})

	win.CreateTrackbar("Thresh", 1, 100, func(pos int, param ...interface{}) {
		edge_thresh := pos

		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(edge_thresh), float64(edge_thresh*3), 3)

		opencv.Zero(cedge)
		// copy edge points
		opencv.Copy(image, cedge, edge)

		win.ShowImage(cedge)

		fmt.Printf("pos = %d\n", pos)
	})
	win.ShowImage(image)

	for {
		key := opencv.WaitKey(20)
		if key == 27 {
			os.Exit(0)
		}
	}

	os.Exit(0)
}
开发者ID:nfillot,项目名称:go-opencv,代码行数:64,代码来源:edge.go


示例16: main

func main() {
	filename := "../data/???.avi"
	if len(os.Args) == 2 {
		filename = os.Args[1]
	} else {
		fmt.Printf("Usage: go run player.go videoname\n")
		os.Exit(0)
	}

	cap := opencv.NewFileCapture(filename)
	if cap == nil {
		panic("can not open video")
	}
	defer cap.Release()

	win := opencv.NewWindow("GoOpenCV: VideoPlayer")
	defer win.Destroy()

	fps := int(cap.GetProperty(opencv.CV_CAP_PROP_FPS))
	frames := int(cap.GetProperty(opencv.CV_CAP_PROP_FRAME_COUNT))
	stop := false

	win.SetMouseCallback(func(event, x, y, flags int) {
		if flags&opencv.CV_EVENT_LBUTTONDOWN != 0 {
			stop = !stop
			if stop {
				fmt.Printf("status: stop")
			} else {
				fmt.Printf("status: palying")
			}
		}
	})
	win.CreateTrackbar("Seek", 1, frames, func(pos int) {
		cur_pos := int(cap.GetProperty(opencv.CV_CAP_PROP_POS_FRAMES))

		if pos != cur_pos {
			cap.SetProperty(opencv.CV_CAP_PROP_POS_FRAMES, float64(pos))
			fmt.Printf("Seek to %d(%d)\n", pos, frames)
		}
	})

	for {
		if !stop {
			img := cap.QueryFrame()
			if img == nil {
				break
			}

			frame_pos := int(cap.GetProperty(opencv.CV_CAP_PROP_POS_FRAMES))
			if frame_pos >= frames {
				break
			}
			win.SetTrackbarPos("Seek", frame_pos)

			win.ShowImage(img)
			key := opencv.WaitKey(1000 / fps)
			if key == 27 {
				os.Exit(0)
			}
		} else {
			key := opencv.WaitKey(20)
			if key == 27 {
				os.Exit(0)
			}
		}
	}

	opencv.WaitKey(0)
}
开发者ID:nfillot,项目名称:go-opencv,代码行数:69,代码来源:player.go


示例17: ProcessImageTest

func ProcessImageTest() {

	log.Print("Try to open webcam.")
	cap := opencv.NewCameraCapture(0)
	if cap == nil {
		panic("can not open camera")
	}

	log.Print("webcame opened.")

	var outputFileName = "testvideo.mpeg"
	var width = 640
	var height = 480
	var fps = 20.0
	var fourcc = opencv.FOURCC('m', 'p', '4', 'v')
	var noOfCapturedFrames = 100

	cap.SetProperty(opencv.CV_CAP_PROP_FRAME_WIDTH, float64(width))
	cap.SetProperty(opencv.CV_CAP_PROP_FRAME_HEIGHT, float64(height))
	cap.SetProperty(opencv.CV_CAP_PROP_FPS, fps)

	log.Print("capturing ", noOfCapturedFrames, " frames and save them to the following file: ", outputFileName)
	log.Print("width: ", width)
	log.Print("height: ", height)
	log.Print("fps: ", fps)
	log.Print("fourcc: ", fourcc)

	var frames []*opencv.IplImage

	for len(frames) < noOfCapturedFrames {
		if cap.GrabFrame() {
			img := cap.RetrieveFrame(1)
			if img != nil {

				var frame = cap.RetrieveFrame(1)
				var copy = opencv.CreateImage(int(width), int(height), frame.Depth(), frame.Channels())
				defer copy.Release()
				opencv.Copy(frame, copy, nil)

				frames = append(frames, copy)

			} else {
				fmt.Println("Image ins nil")
			}
		}
	}

	cap.Release()
	win := opencv.NewWindow("Go-OpenCV Webcam")
	defer win.Destroy()
	for i := 0; i < len(frames); i++ {
		log.Print("displaying frame no: ", i)
		win.ShowImage(frames[i])
		key := opencv.WaitKey(10)
		if key != 0 {
			log.Print(key)
		}
	}

	log.Print("start writing frames to file.")
	var videoWritter = NewVideoWriter(fourcc, float32(fps), opencv.Size{int(width), int(height)})
	videoWritter.SaveAsVideo(frames, outputFileName)

	log.Print("created file with name: ", outputFileName)
	os.Exit(0)
}
开发者ID:mstein11,项目名称:opencv-examples,代码行数:66,代码来源:webcam.go



注:本文中的github.com/lazywei/go-opencv/opencv.NewWindow函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang opencv.IplImage类代码示例发布时间:2022-05-23
下一篇:
Golang glib.ToGObject函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap