android - The image uploaded to s3 have the same image name but different picture i see when i open the image -
i taking picture android phone , uploading s3 ,image getting uploaded ,i can see same image name in s3 picture inside image different 1 uploaded showing old picture new image name.
code:
protected void takepicture() { if (null == cameradevice) { log.e(tag, "cameradevice null"); return; } cameramanager manager = (cameramanager) getsystemservice(context.camera_service); try { cameracharacteristics characteristics = manager.getcameracharacteristics(cameradevice.getid()); size[] jpegsizes = null; if (characteristics != null) { jpegsizes = characteristics.get(cameracharacteristics.scaler_stream_configuration_map).getoutputsizes(imageformat.jpeg); } if (jpegsizes != null && 0 < jpegsizes.length) { width = jpegsizes[0].getwidth(); height = jpegsizes[0].getheight(); } imagereader reader = imagereader.newinstance(width, height, imageformat.jpeg, 1); list<surface> outputsurfaces = new arraylist<surface>(2); outputsurfaces.add(reader.getsurface()); outputsurfaces.add(new surface(textureview.getsurfacetexture())); final capturerequest.builder capturebuilder = cameradevice.createcapturerequest(cameradevice.template_still_capture); capturebuilder.addtarget(reader.getsurface()); capturebuilder.set(capturerequest.control_mode, camerametadata.control_mode_auto); // orientation int rotation = getwindowmanager().getdefaultdisplay().getrotation(); capturebuilder.set(capturerequest.jpeg_orientation, orientations.get(rotation)); final file file = new file(environment.getexternalstoragedirectory() + "/"+name+"_"+dl+".jpg"); final imagereader.onimageavailablelistener readerlistener = new imagereader.onimageavailablelistener() { @override public void onimageavailable(imagereader reader) { image image = null; try { image = reader.acquirelatestimage(); bytebuffer buffer = image.getplanes()[0].getbuffer(); byte[] bytes = new byte[buffer.capacity()]; buffer.get(bytes); save(bytes); mbitmaptosave1 = bitmapfactory.decodebytearray(bytes, 0, bytes.length); mbitmaptosave = bitmapfactory.decodebytearray(bytes, 0, bytes.length); bitmap scaled = bitmap.createscaledbitmap(mbitmaptosave, width, height, true); int w = scaled.getwidth(); int h = scaled.getheight(); // setting post rotate 90 matrix mtx = new matrix(); mtx.postrotate(-180); // rotating bitmap mbitmaptosave = bitmap.createbitmap(scaled, 0, 0, w, h, mtx, true); // mbitmaptosave = bitmap.createbitmap(width+rowpadding/pixelstride,height, bitmap.config.rgb_565); // mbitmaptosave.copypixelstobuffer(buffer); if (detector.isoperational() && mbitmaptosave != null) { frame frame = new frame.builder().setbitmap(mbitmaptosave).build(); sparsearray<face> faces = detector.detect(frame); (index = 0; index < faces.size(); ++index) { face face = faces.valueat(index); } if (faces.size() == 0) { mediaplayer mediaplayer = mediaplayer.create(getapplicationcontext(), r.raw.not); mediaplayer.start(); //toast.maketext(androidcamera2api.this, "face not detected adjust camera properly", toast.length_short).show(); } else { c++; toast.maketext(androidcamera2api.this, "face found " + "\n", toast.length_short).show(); //toast.maketext(androidcamera2api.this, "saved:" + file, toast.length_short).show(); setfiletoupload(); toast.maketext(androidcamera2api.this, "" +c, toast.length_short).show(); // toast.maketext(androidcamera2api.this, "completed" , toast.length_short).show(); }
the setfiletoupload method:
public void setfiletoupload(){ transferobserver transferobserver = transferutility.upload( "train-faces/trainingdata"+"/"+name, /* bucket upload */ name+"_"+dl+".jpg", /* key uploaded object */ filetoupload /* file data upload exists */ ); transferobserverlistener(transferobserver); }
Comments
Post a Comment