Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CV\Scalar values mast be float #55

Open
ta-tikoma opened this issue Apr 27, 2023 · 7 comments
Open

CV\Scalar values mast be float #55

ta-tikoma opened this issue Apr 27, 2023 · 7 comments

Comments

@ta-tikoma
Copy link

Scalar must contains floating point numbers.

Source https://github.com/opencv/opencv/blob/17234f82d025e3bbfbf611089637e5aa2038e7b8/modules/core/misc/java/src/java/core%2BScalar.java#L8

Example:

(new Scalar(78.4263377603, 87.7689143744, 114.895847746))->print()

Output:

[78, 87, 114, 0]

Need:

[78.4263377603, 87.7689143744, 114.895847746, 0]
@BbenWeb1
Copy link

BbenWeb1 commented Apr 29, 2023

Yes return integer not Float. Because he wrote this line
Scalar scalar = Scalar((int)value1, (int)value2, (int)value3, (int)value4);

line 210 in flie opencv2/core/opencv_type.cc

@BbenWeb1
Copy link

BbenWeb1 commented Apr 29, 2023

Convert Line
Scalar scalar = Scalar((int)value1, (int)value2, (int)value3, (int)value4);
To

Scalar scalar = Scalar(value1, value2, value3, value4); 

and Test in Windows
IMG_20230429_114857.jpg

@ta-tikoma
Copy link
Author

@BbenWeb1 thanks for you research!
Do you want to make pull request?

@BbenWeb1
Copy link

BbenWeb1 commented May 2, 2023

@ta-tikoma What system are you working on

@ta-tikoma
Copy link
Author

@ta-tikoma What system are you working on

ubuntu in wsl2

@BbenWeb1
Copy link

BbenWeb1 commented May 2, 2023

@ta-tikoma What system are you working on

ubuntu in wsl2

ok test in Ubuntu 22.04 WSL 2
Capture_2023_05_02_23_39_39_525

@BbenWeb1
Copy link

BbenWeb1 commented May 2, 2023

instal For Ubuntu Wsl2

apt update && apt install -y wget
wget https://raw.githubusercontent.com/php-opencv/php-opencv-packages/master/opencv_4.7.0_amd64.deb && dpkg -i opencv_4.7.0_amd64.deb && rm opencv_4.7.0_amd64.deb
apt update && apt install -y pkg-config cmake git php-dev
git clone https://github.com/BbenWeb1/php-opencv.git
cd php-opencv && phpize && ./configure --with-php-config=/usr/bin/php-config && make && make install
cd  .libs
mv opencv.so  /usr/bin

if php version 8.2

enable php-opencv extension:
echo "extension=opencv.so" > /etc/php/8.2/cli/conf.d/opencv.ini
echo "extension=opencv.so" > /etc/php/8.2/fpm/conf.d/opencv.ini
echo "extension=opencv.so" > /etc/php/8.2/apache2/conf.d/opencv.ini

or php version 8.1

echo "extension=opencv.so" > /etc/php/8.1/cli/conf.d/opencv.ini
echo "extension=opencv.so" > /etc/php/8.1/fpm/conf.d/opencv.ini
echo "extension=opencv.so" > /etc/php/8.1/apache2/conf.d/opencv.ini
cd  
nano test.php

Write
`<?php
namespace CV ;
use CV\Scalar;
(new Scalar(78.4263377603, 87.7689143744, 114.895847746))->print();
print_r((new Scalar(78.4263377603, 87.7689143744, 114.895847746))->val);

?>`
and save

php test.php

DrDub added a commit to DrDub/php-opencv that referenced this issue Dec 8, 2023
DrDub added a commit to DrDub/php-opencv that referenced this issue Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants