Package com.googlecode.javacpp

Examples of com.googlecode.javacpp.BytePointer


        switch (colorMode) {
            case BGR:
                // Determine required buffer size and allocate buffer
                numBytes = avpicture_get_size(PIX_FMT_BGR24, width, height);
                buffer = new BytePointer(av_malloc(numBytes));

                // Assign appropriate parts of buffer to image planes in pFrameRGB
                // Note that pFrameRGB is an AVFrame, but AVFrame is a superset
                // of AVPicture
                avpicture_fill(pFrameRGB, buffer, PIX_FMT_BGR24, width, height);

                // Convert the image into BGR format that OpenCV uses
                img_convert_ctx = sws_getContext(
                        pCodecCtx.width(), pCodecCtx.height(), pCodecCtx.pix_fmt(),
                        width, height, PIX_FMT_BGR24, SWS_BILINEAR, null, null, null);
                if (img_convert_ctx == null) {
                    throw new Exception("Cannot initialize the conversion context.");
                }

                return_image = IplImage.createHeader(width, height, IPL_DEPTH_8U, 3);
                break;

            case GRAY:
                numBytes = avpicture_get_size(PIX_FMT_GRAY8, width, height);
                buffer = new BytePointer(av_malloc(numBytes));
                avpicture_fill(pFrameRGB, buffer, PIX_FMT_GRAY8, width, height);

                // Convert the image into GRAY format that OpenCV uses
                img_convert_ctx = sws_getContext(
                        pCodecCtx.width(), pCodecCtx.height(), pCodecCtx.pix_fmt(),
View Full Code Here


            /* allocate the encoded raw picture */
            picture = avcodec_alloc_frame();
            if (picture != null) {
                int size = avpicture_get_size(c.pix_fmt(), c.width(), c.height());
                BytePointer picture_buf = new BytePointer(av_malloc(size));
                if (picture_buf == null) {
                    av_free(picture);
                    picture = null;
                } else {
                    avpicture_fill(picture, picture_buf, c.pix_fmt(), c.width(), c.height());
                }
            }
            if (picture == null) {
                avcodec_close(c);
                av_freep(video_st);
                video_st = null;
                throw new Exception("Could not allocate picture");
            }

            video_outbuf = null;
            if ((oformat.flags() & AVFMT_RAWPICTURE) == 0) {
                /* allocate output buffer */
                /* XXX: API change will be done */
                /* buffers passed into lav* can be allocated any way you prefer,
                   as long as they're aligned enough for the architecture, and
                   they're freed appropriately (such as using av_free for buffers
                   allocated with av_malloc) */
                video_outbuf_size = imageWidth*imageHeight*4; // ??
                video_outbuf = new BytePointer(av_malloc(video_outbuf_size));
            }
        }

        /* open the output file, if needed */
        if ((oformat.flags() & AVFMT_NOFILE) == 0) {
View Full Code Here

               futur for that */
            av_init_packet(pkt);

            pkt.flags(pkt.flags() | PKT_FLAG_KEY);
            pkt.stream_index(video_st.index());
            pkt.data(new BytePointer(picture));
            pkt.size(sizeof(AVPicture.class));

            ret = av_write_frame(oc, pkt);
        } else {
            /* encode the image */
 
View Full Code Here

        boolean colorrgb   = color_coding == DC1394_COLOR_CODING_RGB8 ||
                             color_coding == DC1394_COLOR_CODING_RGB16;
        boolean coloryuv   = color_coding == DC1394_COLOR_CODING_YUV411 ||
                             color_coding == DC1394_COLOR_CODING_YUV422 ||
                             color_coding == DC1394_COLOR_CODING_YUV444;
        BytePointer imageData = frame.image();

        if ((depth <= 8 || frameEndian.equals(ByteOrder.nativeOrder())) && !coloryuv &&
                (colorMode == ColorMode.RAW || (colorMode == ColorMode.BGR && numChannels == 3) ||
                (colorMode == ColorMode.GRAY && numChannels == 1 && !colorbayer))) {
            if (return_image == null) {
View Full Code Here

        type = CV_MAT_TYPE(type);
        m.type(CV_MAT_MAGIC_VAL | CV_MAT_CONT_FLAG | type);
        m.cols(cols);
        m.rows(rows);
        m.step(cols*CV_ELEM_SIZE(type));
        m.data_ptr(new BytePointer(data));
        m.refcount(null);
        m.hdr_refcount(0);

        return m;
    }
View Full Code Here

        public native CvSparseNode node(); public native CvSparseMatIterator node(CvSparseNode node);
        public native int curidx();        public native CvSparseMatIterator curidx(int curidx);
    }

    public static Pointer CV_NODE_VAL(CvSparseMat mat, CvSparseNode node) {
        return new BytePointer(node).position(mat.valoffset());
    }
View Full Code Here

    public static Pointer CV_NODE_VAL(CvSparseMat mat, CvSparseNode node) {
        return new BytePointer(node).position(mat.valoffset());
    }
    public static IntPointer CV_NODE_IDX(CvSparseMat mat, CvSparseNode node) {
        return new IntPointer(new BytePointer(node).position(mat.idxoffset()));
    }
View Full Code Here

    public static String cvReadString(CvFileNode node, String default_value) {
        if (node == null) {
            return default_value;
        } else if (CV_NODE_IS_STRING(node.tag())) {
            CvString str = node.data_str();
            BytePointer pointer = str.ptr();
            int length = str.len();
            byte[] bytes = new byte[length];
            pointer.capacity(length).asBuffer().get(bytes);
            return new String(bytes);
        } else {
            return null;
        }
    }
View Full Code Here

TOP

Related Classes of com.googlecode.javacpp.BytePointer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.