当前位置: 首页>>代码示例>>Java>>正文


Java Java2DFrameConverter类代码示例

本文整理汇总了Java中org.bytedeco.javacv.Java2DFrameConverter的典型用法代码示例。如果您正苦于以下问题:Java Java2DFrameConverter类的具体用法?Java Java2DFrameConverter怎么用?Java Java2DFrameConverter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Java2DFrameConverter类属于org.bytedeco.javacv包,在下文中一共展示了Java2DFrameConverter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configureThumbnail

import org.bytedeco.javacv.Java2DFrameConverter; //导入依赖的package包/类
/**
 * Configures the thumbnails for the given uploadId
 * @param uploadId The session id
 * @return Result
 * @throws Exception
 * @throws IOException
 * @throws ClientProtocolException
 */
protected StatusResult configureThumbnail(String uploadId) throws Exception, IOException, ClientProtocolException {
    try (FFmpegFrameGrabber frameGrabber = new FFmpegFrameGrabber(videoFile)) {
        frameGrabber.start();
        Java2DFrameConverter converter = new Java2DFrameConverter();
        
        int width = frameGrabber.getImageWidth();
        int height = frameGrabber.getImageHeight();
        long length = frameGrabber.getLengthInTime();
        
        BufferedImage bufferedImage;
        if (thumbnailFile == null) {
            bufferedImage = MyImageUtils.deepCopy(converter.convert(frameGrabber.grabImage()));
            thumbnailFile = File.createTempFile("insta", ".jpg");
            
            log.info("Generated thumbnail: " + thumbnailFile.getAbsolutePath());
            ImageIO.write(bufferedImage, "JPG", thumbnailFile);
        } else {
            bufferedImage = ImageIO.read(thumbnailFile);
        }

        
        holdOn();
        
        StatusResult thumbnailResult = api.sendRequest(new InstagramUploadPhotoRequest(thumbnailFile, caption, uploadId));
        log.info("Thumbnail result: " + thumbnailResult);
        
        StatusResult configureResult = api.sendRequest(InstagramConfigureVideoRequest.builder().uploadId(uploadId)
                    .caption(caption)
                    .duration(length)
                    .width(width)
                    .height(height)
                    .build());
        
        log.info("Video configure result: " + configureResult);

        return configureResult;
    }
}
 
开发者ID:brunocvcunha,项目名称:instagram4j,代码行数:47,代码来源:InstagramUploadVideoRequest.java

示例2: saveVid

import org.bytedeco.javacv.Java2DFrameConverter; //导入依赖的package包/类
public void saveVid(File f, int width, int fps, ProgressDisplay d, ActionListener onFinish) {
	saveStopped = false;
	new Thread(() -> {
		try {
			d.setProgress(0, "Starting export");
			d.setCancel(ae -> saveStopped = true);

			String name	= f.getName();
			int dotIdx	= name.lastIndexOf('.');
			if(dotIdx !=- 1)
				name = name.substring(0, dotIdx);
			String ext = ".mp4";

			File out = StringUtil.resolveConflictName(f.getParentFile(), name+ext, false);

			int height = (int)Math.round(width * getSourceHeight()/(float)getSourceWidth());
			height = height %2 == 0 ? height : height + 1; 
			FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(out.getAbsolutePath(), width, height);
			recorder.setFrameRate(fps);
			recorder.setFormat("mp4");
			recorder.setPixelFormat(avutil.AV_PIX_FMT_YUV420P);
			//recorder.setVideoCodec(avcodec.AV_CODEC_ID_H264);
			recorder.setVideoBitrate(recorder.getImageWidth() * recorder.getImageHeight() * fps * 10);

			recorder.setVideoQuality(.1);
			recorder.start();

			for(int i = 0; i < frames && !saveStopped; i++) {
				try {
					setX(i/(float)(frames-1));
					d.setProgress((i/(float)(frames-1))*.95f, "Writing frame "+i+" of " + frames);
					BufferedImage frame = renderFrame(width);
					BufferedImage img = new BufferedImage(frame.getWidth(), frame.getHeight(), BufferedImage.TYPE_INT_RGB);
					img.getGraphics().drawImage(frame, 0, 0, null);
					recorder.record(new Java2DFrameConverter().convert(img), avutil.AV_PIX_FMT_ARGB);

				} catch (Exception e) {
					e.printStackTrace();
				}
			}
			d.setProgress(.98, "Finishing export...");
			recorder.stop();
			recorder.close();
		} catch (Exception e1) {
			e1.printStackTrace();
		} finally {
			if(onFinish != null)
				SwingUtilities.invokeLater(() -> onFinish.actionPerformed(new ActionEvent(this, ActionEvent.ACTION_FIRST, "save")));
		}
	}).start();
}
 
开发者ID:CalebKussmaul,项目名称:GIFKR,代码行数:52,代码来源:Animation.java

示例3: getFrame

import org.bytedeco.javacv.Java2DFrameConverter; //导入依赖的package包/类
@Override
public BufferedImage getFrame(int gifFrame) {
	
	BufferedImage frame = null;
	
	try {
		g.setFrameNumber(gifFrame+1);
		frame = new Java2DFrameConverter().convert(g.grabImage());
	} catch (Exception e) {
		e.printStackTrace();
	}
	return frame == null? new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR) : frame;
}
 
开发者ID:CalebKussmaul,项目名称:GIFKR,代码行数:14,代码来源:VidImageSequence.java

示例4: Equalize

import org.bytedeco.javacv.Java2DFrameConverter; //导入依赖的package包/类
public IplImage Equalize(BufferedImage bufferedimg) {
	Java2DFrameConverter converter1 = new Java2DFrameConverter();
	OpenCVFrameConverter.ToIplImage converter2 = new OpenCVFrameConverter.ToIplImage();
	IplImage iploriginal = converter2.convert(converter1.convert(bufferedimg));
	IplImage srcimg = IplImage.create(iploriginal.width(), iploriginal.height(), IPL_DEPTH_8U, 1);
	IplImage destimg = IplImage.create(iploriginal.width(), iploriginal.height(), IPL_DEPTH_8U, 1);
	cvCvtColor(iploriginal, srcimg, CV_BGR2GRAY);
	cvEqualizeHist(srcimg, destimg);
	return destimg;
}
 
开发者ID:MeAnupSarkar,项目名称:ExoVisix,代码行数:11,代码来源:ColoredObjectTracker.java

示例5: getBufferedImage

import org.bytedeco.javacv.Java2DFrameConverter; //导入依赖的package包/类
/**
 * Copies this {@link WPIImage} into a {@link BufferedImage}.
 * This method will always generate a new image.
 *
 * @return a copy of the image
 */
public BufferedImage getBufferedImage() {
    validateDisposed();
    ToIplImage toIplImage = new ToIplImage();
    Frame frame = toIplImage.convert(this.image);
    Java2DFrameConverter frameConverter = new Java2DFrameConverter();
    return frameConverter.convert(frame);
}
 
开发者ID:Roobotics-FRC,项目名称:wpijavacv-fork,代码行数:14,代码来源:WPIImage.java

示例6: makeRandomBufferedImage

import org.bytedeco.javacv.Java2DFrameConverter; //导入依赖的package包/类
BufferedImage makeRandomBufferedImage(int height, int width, int channels) {
    Mat img = makeRandomImage(height, width, channels);

    OpenCVFrameConverter.ToMat c = new OpenCVFrameConverter.ToMat();
    Java2DFrameConverter c2 = new Java2DFrameConverter();

    return c2.convert(c.convert(img));
}
 
开发者ID:deeplearning4j,项目名称:DataVec,代码行数:9,代码来源:TestNativeImageLoader.java

示例7: BufferedImageToIplImage

import org.bytedeco.javacv.Java2DFrameConverter; //导入依赖的package包/类
public static IplImage BufferedImageToIplImage(BufferedImage src) {
  OpenCVFrameConverter.ToIplImage grabberConverter = new OpenCVFrameConverter.ToIplImage();
  Java2DFrameConverter jconverter = new Java2DFrameConverter();
  return grabberConverter.convert(jconverter.convert(src));
}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:6,代码来源:Vision.java

示例8: IplImageToBufferedImage

import org.bytedeco.javacv.Java2DFrameConverter; //导入依赖的package包/类
public static BufferedImage IplImageToBufferedImage(IplImage src) {
  OpenCVFrameConverter.ToIplImage grabberConverter = new OpenCVFrameConverter.ToIplImage();
  Java2DFrameConverter converter = new Java2DFrameConverter();
  Frame frame = grabberConverter.convert(src);
  return converter.getBufferedImage(frame, 1);
}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:7,代码来源:Vision.java

示例9: IplImageToBufferedImage

import org.bytedeco.javacv.Java2DFrameConverter; //导入依赖的package包/类
/**
 * new way of converting IplImages to BufferedImages
 * 
 * @param src
 * @return
 */
public static BufferedImage IplImageToBufferedImage(IplImage src) {
	OpenCVFrameConverter.ToIplImage grabberConverter = new OpenCVFrameConverter.ToIplImage();
	Java2DFrameConverter converter = new Java2DFrameConverter();
	Frame frame = grabberConverter.convert(src);
	return converter.getBufferedImage(frame, 1);
}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:13,代码来源:OpenCVUtils.java

示例10: Chronometer

import org.bytedeco.javacv.Java2DFrameConverter; //导入依赖的package包/类
Chronometer(Rectangle roi, IplImage image, long startTime) {
    this.roi = (Rectangle)roi.clone();
    this.startTime = startTime;
    this.converter = new OpenCVFrameConverter.ToIplImage();
    this.chronoImage = new BufferedImage(roi.width, roi.height, Java2DFrameConverter.getBufferedImageType(converter.convert(image)));
    this.chronoGraphics = (Graphics2D)chronoImage.getGraphics();

    Font bigFont, smallFont;
    FontMetrics bigFontMetrics;
    Rectangle2D bounds;
    int fontSize = 10;
    do {
        bigFont   = new Font("Sans", Font.BOLD, fontSize);
        smallFont = new Font("Sans", Font.BOLD, fontSize*9/10);
        bigFontMetrics = chronoGraphics.getFontMetrics(bigFont);
        bounds = bigFontMetrics.getStringBounds("0′00″0", chronoGraphics);
        fontSize += 1;
    } while (bounds.getWidth()*1.1 < roi.width && bounds.getHeight()*1.1 < roi.height);
    this.bigFont = bigFont;
    this.smallFont = smallFont;
    this.bigFontMetrics = bigFontMetrics;
    this.bounds = bounds;

    chronoGraphics.setBackground(Color.WHITE);
    chronoGraphics.setColor(Color.BLACK);
    chronoGraphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
}
 
开发者ID:bytedeco,项目名称:procamtracker,代码行数:28,代码来源:Chronometer.java

示例11: draw

import org.bytedeco.javacv.Java2DFrameConverter; //导入依赖的package包/类
public void draw(IplImage image) {
    long time;
    if (startTime < 0) {
        startTime = System.currentTimeMillis();
        time = 0;
    } else {
        time = System.currentTimeMillis() - startTime;
    }
    long minutes = time/1000/60;
    long seconds = time/1000 - minutes*60;
    long deciseconds = time/100 - seconds*10 - minutes*600;

    chronoGraphics.clearRect(0, 0, chronoImage.getWidth(), chronoImage.getHeight());
    chronoGraphics.setFont(bigFont);
    int x = (int)((roi.width -bounds.getWidth ())/2 - bounds.getX()),
        y = (int)((roi.height-bounds.getHeight())/2 - bounds.getY());
    chronoGraphics.drawString(Long.toString(minutes),  x, y); x+=bigFontMetrics.stringWidth("0");
    chronoGraphics.drawString("′",  x, y);        x+=bigFontMetrics.stringWidth("′");
    chronoGraphics.drawString((seconds < 10 ?
                      "0" : "") + seconds, x, y); x+=bigFontMetrics.stringWidth("00");
    chronoGraphics.drawString("″",  x, y);        x+=bigFontMetrics.stringWidth("″");
    chronoGraphics.setFont(smallFont);
    chronoGraphics.drawString(Long.toString(deciseconds), x, y);
    if (roi.x < 0) {
        roi.x += image.width();
    }
    if (roi.y < 0) {
        roi.y += image.height();
    }
    Java2DFrameConverter.copy(chronoImage, converter.convert(image), 1.0, image.nChannels() == 4, roi);
}
 
开发者ID:bytedeco,项目名称:procamtracker,代码行数:32,代码来源:Chronometer.java

示例12: convertAndKeepInMemory

import org.bytedeco.javacv.Java2DFrameConverter; //导入依赖的package包/类
private IplImage convertAndKeepInMemory(BufferedImage original) {
  Java2DFrameConverter converter1 = new Java2DFrameConverter();
  ToIplImage converter2 = new ToIplImage();
  // we need to keep these from being garbage collected
  Frame frame = converter1.convert(original);
  doNotGarbageCollect.add(frame);
  return converter2.convert(frame);
}
 
开发者ID:OsuCelebrity,项目名称:OsuCelebrity,代码行数:9,代码来源:OsuRobot.java

示例13: getScreenshot

import org.bytedeco.javacv.Java2DFrameConverter; //导入依赖的package包/类
private IplImage getScreenshot(Rectangle region) throws IOException {
  BufferedImage bufferedScreenshot = toGrayScale(robot.createScreenCapture(region));
  // writing this image is very fast, so I'd like to keep it for adjusting offsets
  try {
    ImageIO.write(bufferedScreenshot, "BMP", new File("screenshot.bmp"));
  } catch (Exception e) {
    log.debug("error writing screenshot", e);
  }

  Java2DFrameConverter converter1 = new Java2DFrameConverter();
  ToIplImage converter2 = new ToIplImage();
  Frame frame = converter1.convert(bufferedScreenshot);
  IplImage screenshot = converter2.convert(frame);
  return screenshot;
}
 
开发者ID:OsuCelebrity,项目名称:OsuCelebrity,代码行数:16,代码来源:OsuRobot.java

示例14: ScreenConverter

import org.bytedeco.javacv.Java2DFrameConverter; //导入依赖的package包/类
public ScreenConverter() {
    frameConverter = new OpenCVFrameConverter.ToMat();
    imageConverter = new Java2DFrameConverter();
}
 
开发者ID:h2r,项目名称:burlap_ale,代码行数:5,代码来源:ScreenConverter.java

示例15: BufferedImageToFrame

import org.bytedeco.javacv.Java2DFrameConverter; //导入依赖的package包/类
public static Frame BufferedImageToFrame(BufferedImage src) {
  Java2DFrameConverter jconverter = new Java2DFrameConverter();
  return jconverter.convert(src);
}
 
开发者ID:MyRobotLab,项目名称:myrobotlab,代码行数:5,代码来源:Vision.java


注:本文中的org.bytedeco.javacv.Java2DFrameConverter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。