Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.google.protobuf.Struct;
import com.viam.common.v1.Common;
import com.viam.component.camera.v1.Camera.Format;
import com.viam.component.camera.v1.Camera.Image;
import com.viam.sdk.core.component.Component;
import com.viam.sdk.core.resource.Resource;
Expand Down Expand Up @@ -47,13 +46,6 @@ public static Camera fromRobot(final RobotClient robot, final String name) {
return robot.getResource(Camera.class, named(name));
}

/**
* @deprecated please utilize getImages instead
*/
@Deprecated
public abstract Image getImage(final Format format,
final Optional<Struct> extra);

public abstract Entry<List<Image>, Common.ResponseMetadata> getImages(
final Optional<List<String>> filterSourceNames,
final Optional<Struct> extra);
Expand All @@ -62,35 +54,4 @@ public Entry<List<Image>, Common.ResponseMetadata> getImages() {
return getImages(Optional.empty(), Optional.empty());
}

@Deprecated
static Format mimeToFormat(final String mimeType) {
switch (mimeType) {
case "image/jpeg":
return Format.FORMAT_JPEG;
case "image/png":
return Format.FORMAT_PNG;
case "image/vnd.viam.rgba":
return Format.FORMAT_RAW_RGBA;
case "image/vnd.viam.dep":
return Format.FORMAT_RAW_DEPTH;
default:
return Format.FORMAT_UNSPECIFIED;
}
}

@Deprecated
static String formatToMime(final Format format) {
switch (format) {
case FORMAT_JPEG:
return "image/jpeg";
case FORMAT_PNG:
return "image/png";
case FORMAT_RAW_RGBA:
return "image/vnd.viam.rgba";
case FORMAT_RAW_DEPTH:
return "image/vnd.viam.dep";
default:
return "unknown";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,6 @@ public List<Common.Geometry> getGeometries(final Optional<Struct> extra) {
return client.getGeometries(builder.build()).getGeometriesList();
}

@Override
@Deprecated
/*
* @deprecated please utilize getImages instead
*/
public Image getImage(final Format format,
Optional<Struct> extra) {
final GetImageRequest.Builder builder = GetImageRequest.newBuilder().
setName(getName().getName()).
setMimeType(Camera.formatToMime(format));
extra.ifPresent(builder::setExtra);
final GetImageResponse resp = client.getImage(builder.build());
final Image.Builder imgBuilder = Image.newBuilder().
setSourceName(getName().getName()).
setImage(resp.getImage());

return imgBuilder.setFormat(Camera.mimeToFormat(resp.getMimeType())).build();
}

@Override
public Entry<List<Image>, ResponseMetadata> getImages(final Optional<List<String>> filterSourceNames,
final Optional<Struct> extra) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
import com.viam.common.v1.Common.Geometry;
import com.viam.common.v1.Common.GetGeometriesResponse;
import com.viam.common.v1.Common.ResponseMetadata;
import com.viam.component.camera.v1.Camera.GetImageRequest;
import com.viam.component.camera.v1.Camera.GetImageResponse;
import com.viam.component.camera.v1.Camera.GetImagesRequest;
import com.viam.component.camera.v1.Camera.GetImagesResponse;
import com.viam.component.camera.v1.Camera.Image;
Expand Down Expand Up @@ -51,24 +49,6 @@ public void getGeometries(Common.GetGeometriesRequest request,
responseObserver.onCompleted();
}

@Override
@Deprecated
/*
* @deprecated please utilize getImages instead
*/
public void getImage(GetImageRequest request,
StreamObserver<GetImageResponse> responseObserver) {
final Camera camera = getResource(
Camera.named(request.getName()));
final Image result = camera.getImage(Camera.mimeToFormat(request.getMimeType()),
Optional.of(request.getExtra()));

responseObserver.onNext(
GetImageResponse.newBuilder().setImage(result.getImage())
.setMimeType(Camera.formatToMime(result.getFormat())).build());
responseObserver.onCompleted();
}

@Override
public void getImages(GetImagesRequest request,
StreamObserver<GetImagesResponse> responseObserver) {
Expand Down
10 changes: 4 additions & 6 deletions core/sdk/src/main/kotlin/com/viam/sdk/core/util/Media.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@file:JvmName("MediaUtils")
package com.viam.sdk.core.util

import com.viam.component.camera.v1.Camera.Format
import com.viam.component.camera.v1.Camera.Image
import java.nio.ByteBuffer

Expand All @@ -18,7 +17,6 @@ data class ImageDimensions(val width: Int, val height: Int) {
* Get the dimensions of an image from its data and mime-type.
*
* Only specific mime-types are supported: PNG, JPEG, and a custom vnd.viam.rgba.
* The corresponding [Format] are [Format.FORMAT_PNG], [Format.FORMAT_JPEG], and [Format.FORMAT_RAW_RGBA].
*
* @param image the byte data of the image
* @param mimeType the mime-type of the image
Expand All @@ -37,25 +35,25 @@ fun getDimensions(image: Iterable<Byte>, mimeType: String): ImageDimensions {
}

/**
* The dimensions of the image, if [Image.getFormat] returns a supported [Format].
* The dimensions of the image based on its mime type.
* See [getDimensions] for more details.
*/
val Image.dimensions: ImageDimensions?
get() = try {
getDimensions(this.image, this.format.name)
getDimensions(this.image, this.mimeType)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does anything important rely on this? I don't think we should support this anymore

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd wait for confirmation from @njooma but I think it's probably fine to get rid of.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to support dimensions i believe for some vision methods that require height/width IIRC

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hexbabe what're your thoughts on getting rid of it?

} catch (e: Exception) {
null
}

/**
* The width of the image, if [Image.getFormat] returns a supported [Format].
* The width of the image based on its mime type.
* See [getDimensions] for more details.
*/
val Image.width: Int?
get() = this.dimensions?.width

/**
* The height of the image, if [Image.getFormat] returns a supported [Format].
* The height of the image based on its mime type.
* See [getDimensions] for more details.
*/
val Image.height: Int?
Expand Down
Loading