You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Android Demo DetectorActivity landscape orientation problem #9412
Actually in the debug preview there is also nothing.
And in the main view, for example on my screenshot 2, we can see false (train) detected object (on the left)
If you look at the preview screen bottom right you will see that your input is coming through on it's side. That debug preview screen is what goes through the model. As it is on it's side the model will not preform as expected. That's why in landscape you're getting nonsense predictions. Almost all image recognition problems are NOT rotation invariant.
On another note, you'll notice that the blue train box is being drawn on a part of the image that isn't in the preview that goes through the model. That's because the rectangle drawing functions don't work correctly when the app is changed to landscape. I am also struggling with this issue and hope @andrewharp is able to comment on that particular issue. (Probably not a bug but rather me being too rubbish at understanding the source code),
Yes that is the way to force the rotation. I also found problems with the rotation. I guess this is kind of linked with #9416 that @andrewharp has been assisting with.
Regarding the boxes on the main view, it is on my todo list to try and figure out but will be a few weeks away if anyone else has any ideas?
I tried to force rotation in the different part of code.
Rects on the main view looks better now (I guess it shows normal width/height of every detected car now),
but they are still at the wrong position..
I am also struggling with landscape mode for drawing correct rectangles around objects. Debug looks totally valid only preview side is remaining. any progress on this?
I'm just doing this for fun, it's just cool that we can run Tensorflow just everywhere and using different programming frameworks, languages, devices
and Java is powerful for end-products - works on Windows/Ubuntu/Mac
I've made a fix for this internally, should show up in the next push. You'll still have to manually change the orientation of the Activity in AndroidManifest.xml, but everything else should just work afterwards.
I have integrated tensor flow with YOLO in android. and I want to detect the objects in landscape and I also want camera preview in full screen.
If I change the camera preview size. Object detection not working. Please help me.
I have changed to support in landscape mode by changing
sensorOrientation = screenOrientation;
Change the camera preview size by adding
private static Size DESIRED_PREVIEW_SIZE = new Size(1280, 720);
and I have commented that method chooseOptimalSize() to show camera in full screen.
Please help me to show the preview of a camera in full screen and also support for a landscape to detect the objects
I want to get the distance of detected objects. Please guide me how to get the distance of detected objects. Actually, I already searched on the internet and I didn't get any idea.
Please help me.
Just pulled the latest demo, still cannott change to landscape mode by simply changing the screenOrientation in manifest.xml, and change to auto rotate didn`t work for me @prasanna532
Here`s my work around:
In DetectorActivity: sensorOrientation = 0 - getScreenOrientation();//here change rotation to 0
In MultiBoxTracker:
final boolean rotated = sensorOrientation % 180 != 90;//here change == to !=
frameToCanvasMatrix =
ImageUtils.getTransformationMatrix(
frameWidth,
frameHeight,
(int) (multiplier * (rotated ? frameHeight : frameWidth)),
(int) (multiplier * (rotated ? frameWidth : frameHeight)),
sensorOrientation+90,//here add 90 to degree
false);
borderedText.drawText(canvas, trackedPos.left + cornerSize, trackedPos.top, labelString,90);//here draw from top, and modify the drawText function in env/BorderedText
In env/BorderedText:
//Add a new drawText function
public void drawText(final Canvas canvas, final float posX, final float posY, final String text, float angle)
{
if(angle != 0){
canvas.rotate(angle, posX, posY);
}
canvas.drawText(text, posX, posY, exteriorPaint);
canvas.drawText(text, posX, posY, interiorPaint);
if(angle != 0){
canvas.rotate(-angle, posX, posY);
}
}
Reacted by Bluzy, Shotaro-N, Mike D. and Ibai Díez Oronoz
I commented out the portion in set fragment, which is calling the legacy connection fragment. Then landscape mode seems to work without any changes(except in the manifest file) - camera2api being used. (Incase, we want to retain the if..else block and want the legacy fragment to be called, then need to make changes in legacyconnectionfragment.java file corresponding to landscape mode.)
I have the same problem with newest example file. Please guide me how to change the screen orientation to landscape. I have tried all suggested modification here, but it does not work.
I am having some issue camera is opening only 70% to the screen Remaining 30% of the screen is black. Any suggestion or solution on how to fix that?
I've solved the landscape orientation problem thanks to @MICHAEL-ZENZ. However, the issue of 30% black rectangle @prasanna532 at the bottom stayed in both landscape and vertical orientations. Please, need help.
Reacted by jsn5, Rodrigo, Ibai Díez Oronoz and Luccas Pereira Nunes
Activity
jubjamie commentedon Apr 24, 2017
By any chance are you referring to the fact that it draws them correctly in the debug preview but off to the side and squished in the main view?
anonym24 commentedon Apr 24, 2017
Actually in the debug preview there is also nothing.
And in the main view, for example on my screenshot 2, we can see false (train) detected object (on the left)
portrait

landscape

jubjamie commentedon Apr 24, 2017
If you look at the preview screen bottom right you will see that your input is coming through on it's side. That debug preview screen is what goes through the model. As it is on it's side the model will not preform as expected. That's why in landscape you're getting nonsense predictions. Almost all image recognition problems are NOT rotation invariant.
On another note, you'll notice that the blue train box is being drawn on a part of the image that isn't in the preview that goes through the model. That's because the rectangle drawing functions don't work correctly when the app is changed to landscape. I am also struggling with this issue and hope @andrewharp is able to comment on that particular issue. (Probably not a bug but rather me being too rubbish at understanding the source code),
anonym24 commentedon Apr 24, 2017
I tried this:
So debug preview looks fine now
So now it's only main view.
I'm not sure where to look, but I guess here: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/android/src/org/tensorflow/demo/TensorFlowYoloDetector.java#L205
jubjamie commentedon Apr 24, 2017
Yes that is the way to force the rotation. I also found problems with the rotation. I guess this is kind of linked with #9416 that @andrewharp has been assisting with.
Regarding the boxes on the main view, it is on my todo list to try and figure out but will be a few weeks away if anyone else has any ideas?
anonym24 commentedon Apr 29, 2017
I tried to force rotation in the different part of code.
Rects on the main view looks better now (I guess it shows normal width/height of every detected car now),
but they are still at the wrong position..
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/android/src/org/tensorflow/demo/DetectorActivity.java#L297
solix commentedon Jul 27, 2017
I am also struggling with landscape mode for drawing correct rectangles around objects. Debug looks totally valid only preview side is remaining. any progress on this?
bobeo commentedon Sep 29, 2017
I have the same issue. Any luck till recently?
Nanamare commentedon Nov 2, 2017
I solved this problem.
bobeo commentedon Nov 2, 2017
@Nanamare can you tell us how you solved the issue?
andrewharp commentedon Nov 2, 2017
@Nanamare We'd love to have this as a contribution, if you'd be up for submitting a pull request!
anonym24 commentedon Nov 2, 2017
@Nanamare great, if the problem was related to
List<Recognition> recognizeImage(final Bitmap bitmap)method (https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/android/src/org/tensorflow/demo/TensorFlowYoloDetector.java#L134)then maybe you understand code pretty well and could also help with Yolo detector in Java for Windows/Ubuntu
I already made a project in IntelliJ IDEA, I posted a result and full java classes from the project in my question https://stackoverflow.com/questions/47077983/yolo-detector-in-java
I got some negative votes, but I don't care:)
I'm just doing this for fun, it's just cool that we can run Tensorflow just everywhere and using different programming frameworks, languages, devices
and Java is powerful for end-products - works on Windows/Ubuntu/Mac
andrewharp commentedon Nov 2, 2017
I've made a fix for this internally, should show up in the next push. You'll still have to manually change the orientation of the Activity in AndroidManifest.xml, but everything else should just work afterwards.
bobeo commentedon Nov 4, 2017
@gunan @andrewharp will this work with screenOrientation="sensor" or screenOrientation="fullSensor"?
Thanks.
anonym24 commentedon Dec 4, 2017
I downloaded the latest android example project and set
android:screenOrientation="landscape"debug is ok, but still something wrong with main ui view and its orientation:
TF Detect (SSD-Mobilene) Activity
p.s. I fixed java project (windows/ubuntu) for tensorflow yolo2/tiny yolo detector: https://stackoverflow.com/a/47632412/7767664
mfp305629415 commentedon Jan 9, 2018
Have you solved it, please?
annaisabel93 commentedon Mar 16, 2018
@andrewharp I changed the orientation but it stays just as @anonym24 described... Any idea on how to fix this?
prasanna532 commentedon Aug 14, 2018
I am having some issue camera is opening only 70% to the screen Remaining 30% of the screen is black. Any suggestion or solution how to fix that?
shruti-techindustan commentedon Nov 15, 2018
Hi
I have integrated tensor flow with YOLO in android. and I want to detect the objects in landscape and I also want camera preview in full screen.
If I change the camera preview size. Object detection not working. Please help me.
I have changed to support in landscape mode by changing
sensorOrientation = screenOrientation;
Change the camera preview size by adding
private static Size DESIRED_PREVIEW_SIZE = new Size(1280, 720);
and I have commented that method chooseOptimalSize() to show camera in full screen.
Please help me to show the preview of a camera in full screen and also support for a landscape to detect the objects
Thanks
Shruti
prasanna532 commentedon Nov 16, 2018
@shruti-mahajan
change your mobile setting to auto rotate then it will detect the objects in any mode.
shruti-techindustan commentedon Nov 21, 2018
Ok, Thanks
shruti-techindustan commentedon Nov 21, 2018
Hi
I want to get the distance of detected objects. Please guide me how to get the distance of detected objects. Actually, I already searched on the internet and I didn't get any idea.
Please help me.
Thanks
anonym24 commentedon Nov 21, 2018
@shruti-mahajan you should not ask for help for such tasks here, it's not about TensorFlow at all.
michaelzenz commentedon Feb 19, 2019
Just pulled the latest demo, still cannott change to landscape mode by simply changing the screenOrientation in manifest.xml, and change to auto rotate didn`t work for me @prasanna532
Here`s my work around:
In DetectorActivity:
sensorOrientation = 0 - getScreenOrientation();//here change rotation to 0In MultiBoxTracker:
In env/BorderedText:
erpsindhu commentedon Jun 19, 2019
I commented out the portion in set fragment, which is calling the legacy connection fragment. Then landscape mode seems to work without any changes(except in the manifest file) - camera2api being used. (Incase, we want to retain the if..else block and want the legacy fragment to be called, then need to make changes in legacyconnectionfragment.java file corresponding to landscape mode.)
raymondsutjiadi commentedon Jul 10, 2019
I have the same problem with newest example file. Please guide me how to change the screen orientation to landscape. I have tried all suggested modification here, but it does not work.
mrprimle commentedon Dec 29, 2020
I've solved the landscape orientation problem thanks to @MICHAEL-ZENZ. However, the issue of 30% black rectangle @prasanna532 at the bottom stayed in both landscape and vertical orientations. Please, need help.