#QR camera help

1 messages ยท Page 1 of 1 (latest)

zinc bramble
#

I'll try sending the pics here

#

first pic is the setting for the raw image

second shows what I have in the camera scene

third shows what happens when I build the app

#

The goal is to be able to have the camera in the top third of the screen and have a background around the rest of the image

coral lintel
#

You are aware of windows button + shift + S?

#

Or don't you have discord on your desktop?

zinc bramble
#

yes but I also wanted to send stuff from my phone

#

I am aware just stupid at times

coral lintel
#

Yeah thats more readable

zinc bramble
#

Its pretty easy to make it fill the whole screen but Im not quite sure how to make it look good not doing that.

coral lintel
#

Can you make your second picture bigger?

zinc bramble
coral lintel
#

And why has the third picture Discord in it?

zinc bramble
#

just trying to show the cameras warped

coral lintel
#

Ahh

#

What kind of code did you write for this?

zinc bramble
#

I copied from a video. I can paste the code real quick one sec

coral lintel
#

Is this all?

zinc bramble
#

yup

#

thats all I have so far

#

it makes and displays a camera and will scan qr codes. the displayed camera just looks warped when I do anything other than filling the entire display with it

coral lintel
#

The white box is where you want to show the camera?

zinc bramble
#

basically. I would like to be able to resize that white box even more to make it perfectly square. but rn the camera isnt even showing in the white box

coral lintel
#

Can you show how you set up QRCam in your Unity Inspector?

zinc bramble
coral lintel
#

Did you comment that out?

zinc bramble
#

yeah. that is from the way that the QR scanner code I used displayed the camera. It didnt work with portrait mode apps so I commented it out. I will delete it later

coral lintel
#

Geesh, what a code ๐Ÿ˜›

#

Anyhow,
background.texture = camTexture;

#

And your background is not the same aspect ratio of your cam

zinc bramble
#

i see.

#

is there a way to i guess set the background to part of the camTexture?

coral lintel
#
        float ratio = (float)camTexture.width / (float)camTexture.height;
        fit.aspectRatio = ratio;

        float scaleeY = camTexture.videoVerticallyMirrored ? -1f : 1f;
        background.rectTransform.localScale = new Vector3(1f, scaleeY, 1f);

        int orient = -camTexture.videoRotationAngle;
        background.rectTransform.localEulerAngles = new Vector3(0, 0, orient);```
This whole part needs a Debug.Log to see what's what
#

There is some fuckery going on there I don't understand.

#

Maybe set your background to that ratio

zinc bramble
#

lol yeah thats all for orientation as far as the tutorial I watched is concerned

coral lintel
#

The basics is not that difficult to be honest.
Connect to cam
Get picture from cam
Set picture on canvas

zinc bramble
#

yeah its suprisingly simple

#

but making it look right is a real pain

#

you are right it probably is in that section you pointed out tho

coral lintel
#

Well can you debug.log those values?

#

Otherwise you need to start over and scrap 80% of this code.

zinc bramble
#

maybe. Im not too familiar with that yet

zinc bramble
#

what do you mean log? I am not sure what I need to change or what I would be looking for

coral lintel
#
        float ratio = (float)camTexture.width / (float)camTexture.height;
        fit.aspectRatio = ratio;

        float scaleeY = camTexture.videoVerticallyMirrored ? -1f : 1f;
        background.rectTransform.localScale = new Vector3(1f, scaleeY, 1f);

        int orient = -camTexture.videoRotationAngle;
        background.rectTransform.localEulerAngles = new Vector3(0, 0, orient);
        Debug.unityLogger.logEnabled = true;
Debug.Log(ratio, scaleeY, orient);
zinc bramble
#

this is what gets logged every frame

coral lintel
#

Can you make your white box that ratio?

#

You can simply do x=1 z=1.7778

#

or Y

zinc bramble
#

is that in the rect transform part of the inspector?

coral lintel
#

Still honestly, we have been at it for 50 minutes now. Just copy pasting code from the internet is not a good idea ๐Ÿ˜›

#

Yeah your Background one

zinc bramble
#

I have been at it much longer than 50 mins

#

either way I think that changing the aspect ration wont do what I want it to. maybe making the image a square will take going back to square one with this camera code.

#

maybe I could use a mask?

#

like use the whole screen but put another image over the raw image that acts as a mask?

coral lintel
#

I honestly think its an aspect ratio problem. You can see it in your second and third picture

#

Your mobile phone screen has less width

#

So the Star is smaller on the third screen

zinc bramble
#

I am fiddling with this

coral lintel
#

But your camera is stretched on that background square

zinc bramble
#

I was trying to get away with not using that

coral lintel
#

Looks good?

zinc bramble
#

Lol I'm trying to find a way to make it square for the aesthetic of scanning QR codea

coral lintel
#

But this fixed the warp issue

zinc bramble
#

Yup.

coral lintel
#

Amazing ๐Ÿ‘

zinc bramble
#

Thanks for your help

#

Back to square one I go

coral lintel
#

No problem, was a headache issue ๐Ÿ™‚

#

I'm off to bed now, cya around

#

๐Ÿ‘‹