How can I convert the image from jpeg to binary at sender side & binary to jpeg at receiver side?
It is not recommended to do it.
Rather stream your image from mobile to your server using webservices and receive it from server from other device
Try searching for some JPEG Encoders written in J2ME. That will help you, however sending it via SMS is an overkill
Related
I'm using socket.io-stream to share file over socket from server t browser. I'd like to use the same to share audio stream from browser to server. Is it possible? I know that browser audio stream is different from node.js stream, so i need to convert it, how?
Not 100% sure what you're expecting to do with the data, but this answer may be of use to you.
Specifically, I'd suggest you use getUserMedia to get your audio, hook it up to a Script Processor, convert the data, and emit those data chunks to socket.io. Then on your server, you can capture those chunks and write them to your node.js stream. Code samples are at the link; they're fairly lengthy and I don't want to spam, so I won't reproduce them here.
So I want to transfer sound bytes over a websocket from a phone to a server. However according to http://crossbar.io/docs/Features crossbar seems to only implement json and msgpack. Can I stil transfer binary messages over crossbar using some other way?
Also multiple crossbar clients (for eg )seems to only provide json and webpack as de/serialization formats. Am I missing something?
WAMP is primarily intended for transmission of messages, not large (binary) payloads. For small chunks you can encode the audio so that it can be part of a regular WAMP payload. For an example of this for a webcam image, see the Tessel camera example - https://github.com/crossbario/crossbarexamples/tree/master/iotcookbook/device/tessel/camera. This works fine in principle, though there is, of course, the encoding/decoding overhead.
I want to open an image and send it and send to the sockets that are connected in my nodejs server.
The problem is when I'm trying to send some image via socket.write(myImage); because the method write() can't send it as an image object. The "solution" that i've found is to create a buffer from my image, copy in another buffer and parse it to a base64 encode and send this using socket.write(myBase64Img), receive it in my Qt client and decode that image with openCV. the problem is that this is very expensive. There is another way to send my image via TCP sockets?
PS: I can't send the URL of the image, I want to send the image.
Thanks!
You should be able to write the raw image data to the socket without base64-encoding it, just pass a Buffer containing that binary data to write(). You could also stream the data if you don't have the image completely in memory already since that would help save on memory usage.
Assuming that you're dealing with an image that is already on disk, the right way to do this is to stream the image directly from disk to the socket.
var stream = fs.createReadStream(filePath);
stream.pipe(socket);
See the docs for details:
fs.createReadStream
Stream#pipe
I working on a system where we want to show a video stream from a Video Capture card in a browser. The browser connect towards a remote server and fetch a html page that have video in it. This video should be streamed from the client machine where a video capture card is connected.
On client side we running Linux and the capture card is registered as /dev/video0 by Video4Linux2. The browser on client side is Chrome (chromium-browser). On client side we have a webserver (lighttpd) that is possible to use for streaming.
I have looked into the getUserMedia API but it seems to be poor support for that right now. Other toughts that I have had is to use the local webserver or setup a streaming server on client side that stream video source locally.
Any ideas how to design this would be great input for me!
Thanks,
/Peter
Since Chrome does not yet support RT(S)P streaming for the <video> tag you will have to use a plugin for this.
Given it's availability I would suggest using Flash to write simple SWF which finds the correct video source and displays.
If needed you can use one of the many 'Recording Apps' available and strip out the recording part.
I am new to the J2ME technology. And I am making an application which will transfer the text and image(downloaded through http and stored into an ImageItem of a form) from a client mobile to the server mobile using bluetooth. The connection used is SPP. I have succeded to transfer the text message. But I am unable to transfer the image.
Can anyone help me to transfer the image to the server mobile through bluetooth directly without saving it into the phone memory or memory card.,
I would be thankful to you.
javax.microedition.lcdui.Image.getRGB() is the method you are looking for.
If myImageItem is your ImageItem object, the code would look like this:
------------
Image myImage = myImageItem.getImage();
int[] myImageInts = new int[myImage.getHeight() * myImage.getWidth()];
// Beware of OutOfMemoryError here.
myImage.getRGB(myImageInts, 0, myImageInts.length, 0, 0,
myImage.getWidth(), myImage.getHeight());
------------
You can then convert each int in the array into 4 bytes
(in the correct order please)
and feed these to your Connection's OutputStream.
Alternatively, DataOutputStream.writeInt() does the conversion for you.
Well if your server mobile is using Bluetooth and also running an application written by you, then you can create your own protocol to do this.
For image transfer, it is best to send the bytes that were downloaded over HTTP (and used to create the ImageItem), then receive them at the server end and display in the same way.
What is the specific problem you're encountering while doing this?
funkybro
As funkybro suggested, you can use the bytes to transfer the image to the server mobile. For that you need to can just open the output stream of the connection that you have made to the bluetooth server mobile and then write the byte contents on to the output stream.